/*
 * Markit theme for the Django admin (redesign spec §3.3).
 *
 * The forest-and-mint palette is mapped onto Django's own CSS variables, so
 * every stock admin page (and every custom page that already reads those
 * variables) picks it up. The values are copied from the portal's tokens in
 * portal/portal.css; this file does not import it.
 *
 * Loaded from admin/base_site.html straight after Django's dark_mode.css, so
 * the three theme blocks below override Django's, and a custom page's own
 * <style> block still wins over the primitive restyles further down.
 *
 * Theme blocks use Django's selector shape:
 *   light:  :root  and  html[data-theme="light"] (forces light on a dark OS)
 *   dark:   @media (prefers-color-scheme: dark) :root  (the "auto" setting)
 *           html[data-theme="dark"]                    (the header toggle)
 */

/* ---------- Fonts: the portal's self-hosted files, no copy ---------- */
@font-face {
  font-family: "DM Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("../../portal/fonts/dm-sans-normal-latin.6c1e961057d2.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("../../portal/fonts/dm-sans-normal-latin-ext.b9209b52c467.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Playfair Display"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("../../portal/fonts/playfair-display-normal-latin.ef05b30d6e5c.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Playfair Display"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("../../portal/fonts/playfair-display-normal-latin-ext.319e6b2aad48.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Light (default, and forced by the toggle) ---------- */
html[data-theme="light"],
:root {
  --primary: #113C2B;
  --secondary: #1A543E;
  --accent: #D5EADD;
  --primary-fg: #FFFFFF;

  --body-fg: #113C2B;
  --body-bg: #FFFFFF;
  --body-quiet-color: #587165;
  --body-medium-color: #587165;
  --body-loud-color: #113C2B;

  --header-color: #EAF5EE;
  --header-branding-color: #FFFFFF;
  --header-bg: #113C2B;
  --header-link-color: #D5EADD;

  --breadcrumbs-fg: #587165;
  --breadcrumbs-link-fg: #113C2B;
  --breadcrumbs-bg: #EAF5EE;

  --link-fg: #113C2B;
  --link-hover-color: #1A543E;
  --link-selected-fg: #113C2B;

  --hairline-color: #F2F4F3;
  --border-color: #E2E6E4;

  --error-fg: #B8412C;

  --message-success-bg: #EAF5EE;
  --message-warning-bg: #FBF1DC;
  --message-error-bg: #FBE9E5;

  --darkened-bg: #F7F6F2;
  --selected-bg: #EAF5EE;
  --selected-row: #EAF5EE;

  --button-fg: #FFFFFF;
  --button-bg: #113C2B;
  --button-hover-bg: #1A543E;
  --default-button-bg: #113C2B;
  --default-button-hover-bg: #1A543E;
  --close-button-bg: #587165;
  --close-button-hover-bg: #113C2B;
  --delete-button-bg: #B8412C;
  --delete-button-hover-bg: #A33A27;

  --object-tools-fg: #FFFFFF;
  --object-tools-bg: #587165;
  --object-tools-hover-bg: #113C2B;

  --font-family-primary: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Markit tokens the primitives below use. */
  --markit-serif: "Playfair Display", Georgia, serif;
  --markit-accent: #113C2B;          /* checked boxes, focus rings */
  --markit-icon: #7A8B83;            /* social icons (3.59:1 on white) */
  --markit-icon-hover: #113C2B;
  --markit-checkbox-border: #7A8B83; /* control boundary on hover/focus */
  --markit-glow: rgba(213, 234, 221, .5);
  --markit-shadow: 0 8px 32px rgba(17, 60, 43, .04), 0 2px 8px rgba(17, 60, 43, .02);
  --markit-radius-pill: 999px;
  --markit-radius-panel: 24px;
  --markit-radius-input: 12px;
  --markit-radius-tile: 16px;

  /* Shared surfaces and status tones for the custom admin pages (PR F), so
     their own <style> blocks name a tone instead of repeating hex values. */
  --markit-surface-2: #F7F6F2;       /* stat tiles, code and preview wells */
  --markit-btn2-bg: #EAF5EE;         /* secondary (mint) button */
  --markit-btn2-hover-bg: #D5EADD;
  --markit-danger: #B8412C;
  --markit-danger-bg: #FBE9E5;
  --markit-warn: #7A5200;
  --markit-warn-bg: #FBF1DC;
  --markit-ok: #113C2B;
  --markit-ok-bg: #EAF5EE;
  --markit-neutral: #587165;
  --markit-neutral-bg: #F0F2F1;

  color-scheme: light;
}

/* ---------- Dark: the OS setting ("auto") ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #173026;
    --secondary: #11241B;
    --accent: #8FD1A9;
    --primary-fg: #E8F1EC;

    --body-fg: #E8F1EC;
    --body-bg: #11241B;
    --body-quiet-color: #A9BDB3;
    --body-medium-color: #A9BDB3;
    --body-loud-color: #E8F1EC;

    --header-color: #E8F1EC;
    --header-branding-color: #E8F1EC;
    --header-bg: #0C1A14;
    --header-link-color: #8FD1A9;

    --breadcrumbs-fg: #A9BDB3;
    --breadcrumbs-link-fg: #8FD1A9;
    --breadcrumbs-bg: #173026;

    --link-fg: #8FD1A9;
    --link-hover-color: #D5EADD;
    --link-selected-fg: #8FD1A9;

    --hairline-color: #1A3327;
    --border-color: #2A4A38;

    --error-fg: #F08A78;

    --message-success-bg: #233C2F;
    --message-warning-bg: #303B26;
    --message-error-bg: #303228;

    --darkened-bg: #0C1A14;
    --selected-bg: #233C2F;
    --selected-row: #233C2F;

    --button-fg: #113C2B;
    --button-bg: #D5EADD;
    --button-hover-bg: #EAF5EE;
    --default-button-bg: #D5EADD;
    --default-button-hover-bg: #EAF5EE;
    --close-button-bg: #2A4A38;
    --close-button-hover-bg: #3A5E4A;
    --delete-button-bg: #F08A78;
    --delete-button-hover-bg: #F4A396;

    --object-tools-fg: #E8F1EC;
    --object-tools-bg: #2A4A38;
    --object-tools-hover-bg: #3A5E4A;

    --markit-accent: #8FD1A9;
    --markit-icon: #8FA59A;
    --markit-icon-hover: #E8F1EC;
    --markit-checkbox-border: #5E7A6C;
    --markit-glow: rgba(143, 209, 169, .28);
    --markit-shadow: 0 8px 32px rgba(0, 0, 0, .35);

    --markit-surface-2: #173026;
    --markit-btn2-bg: rgba(143, 209, 169, .14);
    --markit-btn2-hover-bg: rgba(143, 209, 169, .24);
    --markit-danger: #F08A78;
    --markit-danger-bg: rgba(240, 138, 120, .14);
    --markit-warn: #F2C66D;
    --markit-warn-bg: rgba(242, 198, 109, .14);
    --markit-ok: #8FD1A9;
    --markit-ok-bg: rgba(143, 209, 169, .14);
    --markit-neutral: #A9BDB3;
    --markit-neutral-bg: rgba(232, 241, 236, .08);

    color-scheme: dark;
  }
}

/* ---------- Dark: the header toggle ---------- */
html[data-theme="dark"] {
  --primary: #173026;
  --secondary: #11241B;
  --accent: #8FD1A9;
  --primary-fg: #E8F1EC;

  --body-fg: #E8F1EC;
  --body-bg: #11241B;
  --body-quiet-color: #A9BDB3;
  --body-medium-color: #A9BDB3;
  --body-loud-color: #E8F1EC;

  --header-color: #E8F1EC;
  --header-branding-color: #E8F1EC;
  --header-bg: #0C1A14;
  --header-link-color: #8FD1A9;

  --breadcrumbs-fg: #A9BDB3;
  --breadcrumbs-link-fg: #8FD1A9;
  --breadcrumbs-bg: #173026;

  --link-fg: #8FD1A9;
  --link-hover-color: #D5EADD;
  --link-selected-fg: #8FD1A9;

  --hairline-color: #1A3327;
  --border-color: #2A4A38;

  --error-fg: #F08A78;

  --message-success-bg: #233C2F;
  --message-warning-bg: #303B26;
  --message-error-bg: #303228;

  --darkened-bg: #0C1A14;
  --selected-bg: #233C2F;
  --selected-row: #233C2F;

  --button-fg: #113C2B;
  --button-bg: #D5EADD;
  --button-hover-bg: #EAF5EE;
  --default-button-bg: #D5EADD;
  --default-button-hover-bg: #EAF5EE;
  --close-button-bg: #2A4A38;
  --close-button-hover-bg: #3A5E4A;
  --delete-button-bg: #F08A78;
  --delete-button-hover-bg: #F4A396;

  --object-tools-fg: #E8F1EC;
  --object-tools-bg: #2A4A38;
  --object-tools-hover-bg: #3A5E4A;

  --markit-accent: #8FD1A9;
  --markit-icon: #8FA59A;
  --markit-icon-hover: #E8F1EC;
  --markit-checkbox-border: #5E7A6C;
  --markit-glow: rgba(143, 209, 169, .28);
  --markit-shadow: 0 8px 32px rgba(0, 0, 0, .35);

  --markit-surface-2: #173026;
  --markit-btn2-bg: rgba(143, 209, 169, .14);
  --markit-btn2-hover-bg: rgba(143, 209, 169, .24);
  --markit-danger: #F08A78;
  --markit-danger-bg: rgba(240, 138, 120, .14);
  --markit-warn: #F2C66D;
  --markit-warn-bg: rgba(242, 198, 109, .14);
  --markit-ok: #8FD1A9;
  --markit-ok-bg: rgba(143, 209, 169, .14);
  --markit-neutral: #A9BDB3;
  --markit-neutral-bg: rgba(232, 241, 236, .08);

  color-scheme: dark;
}

/* ---------- Header and branding ---------- */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
#header { flex-shrink: 0; }
#site-name { font-family: var(--markit-serif); font-weight: 500; }
#site-name a:link, #site-name a:visited { color: var(--header-branding-color); }
.markit-admin-brand { display: inline-flex; align-items: center; gap: 10px; }
.markit-admin-brand img { display: block; height: 28px; width: auto; border-radius: 6px; }
.markit-admin-brand span { font-size: 1.375rem; line-height: 1; letter-spacing: -0.2px; }
#header :focus-visible { outline: 2px solid var(--header-link-color); outline-offset: 2px; }

/* ---------- Type ---------- */
h1 { font-family: var(--markit-serif); font-weight: 500; font-size: 1.75rem; letter-spacing: -0.3px; line-height: 1.2; color: var(--body-loud-color); }
thead th, html #changelist table thead th {
  font-size: 12px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  color: var(--body-quiet-color);
}

/* ---------- Buttons: pills ---------- */
.button, input[type=submit], input[type=button], .submit-row input, a.button,
html .submit-row a.deletelink, html .submit-row a.closelink,
html #changelist .actions .button, .object-tools a {
  border-radius: var(--markit-radius-pill);
}
.button, input[type=submit], input[type=button], .submit-row input, a.button {
  font-weight: 500;
  transition: background .2s cubic-bezier(.16, 1, .3, 1), box-shadow .2s cubic-bezier(.16, 1, .3, 1);
}

/* ---------- Inputs: 12px corners, a 3:1 boundary on hover and focus ---------- */
input:not([type]), input[type=text], input[type=password], input[type=email],
input[type=url], input[type=number], input[type=tel], input[type=search],
textarea, select, .vTextField,
html #changelist #toolbar form input, html #changelist .actions select {
  border-radius: var(--markit-radius-input);
}
input:not([type]):hover, input[type=text]:hover, input[type=password]:hover,
input[type=email]:hover, input[type=url]:hover, input[type=number]:hover,
input[type=tel]:hover, input[type=search]:hover, textarea:hover, select:hover,
input:not([type]):focus, input[type=text]:focus, input[type=password]:focus,
input[type=email]:focus, input[type=url]:focus, input[type=number]:focus,
input[type=tel]:focus, input[type=search]:focus, textarea:focus, select:focus, .vTextField:focus {
  border-color: var(--markit-checkbox-border);
}
input:not([type]):focus, input[type=text]:focus, input[type=password]:focus,
input[type=email]:focus, input[type=url]:focus, input[type=number]:focus,
input[type=tel]:focus, input[type=search]:focus, textarea:focus, select:focus, .vTextField:focus {
  outline: none;
  box-shadow: 0 0 0 4px var(--markit-glow);
}
input[type=checkbox], input[type=radio] { accent-color: var(--markit-accent); }

/* Keyboard focus is always visible, on links and buttons too. */
a:focus-visible, button:focus-visible, .button:focus-visible,
input[type=submit]:focus-visible, input[type=button]:focus-visible,
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible {
  outline: 2px solid var(--markit-accent);
  outline-offset: 2px;
}

/* ---------- Rounded containers ---------- */
.module {
  border: 1px solid var(--border-color);
  border-radius: var(--markit-radius-panel);
  overflow: hidden;
  box-shadow: var(--markit-shadow);
}
/* A change form's fieldsets keep their popups (calendar, autocomplete) unclipped. */
fieldset.module { overflow: visible; }
fieldset.module > h2, fieldset.module > details > summary > h2 {
  border-radius: calc(var(--markit-radius-panel) - 1px) calc(var(--markit-radius-panel) - 1px) 0 0;
}
.module h2, .module caption, .inline-group h2 { padding: 10px 16px; }

/* The changelist itself is a .module: its form and its filter are the panels. */
html #changelist.module {
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  background: transparent;
}
html #changelist .changelist-form-container {
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--markit-radius-panel);
  overflow: hidden;
  box-shadow: var(--markit-shadow);
}
/* On a desktop, a very long email wraps instead of pushing the creator list
   out of its panel; ordinary emails keep a line of their own. */
@media (min-width: 1025px) {
  html #changelist table td.field-emails { overflow-wrap: anywhere; min-width: 18em; }
}
html #changelist #toolbar { margin-bottom: 0; border-top: none; padding: 12px 16px; }
html #changelist .actions { padding: 10px 16px; }
html #changelist .paginator { padding: 10px 16px; margin: 0; border-top: 1px solid var(--hairline-color); }
html #changelist-filter {
  border: 1px solid var(--border-color);
  border-radius: var(--markit-radius-panel);
  overflow: hidden;
}
html #changelist-filter h2 { padding: 12px 16px; }

/* The index's "Recent actions" column: the module is the panel. */
html #content-related { background: transparent; }

/* The sign-in card. */
html .login #container {
  border: 1px solid var(--border-color);
  border-radius: var(--markit-radius-panel);
  box-shadow: var(--markit-shadow);
}
html .login #header { justify-content: center; }

/* ---------- Creator profile icons (changelists, spec §4.3) ---------- */
/* Inline boxes only (no flex), so a row's text reads the same as before the column. */
.markit-social-links { white-space: nowrap; }
.markit-social-link {
  display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center;
  margin: -4px 2px -4px 0; vertical-align: top; border-radius: 50%;
  color: var(--markit-icon);
  transition: color .2s cubic-bezier(.16, 1, .3, 1), background .2s cubic-bezier(.16, 1, .3, 1);
}
a.markit-social-link:link, a.markit-social-link:visited { color: var(--markit-icon); }
a.markit-social-link:hover, a.markit-social-link:focus-visible {
  color: var(--markit-icon-hover);
  background: var(--selected-bg);
  text-decoration: none;
}
.markit-social-link svg { width: 16px; height: 16px; vertical-align: middle; }

/* Date picker: the selected day keeps readable text on the dark --secondary. */
.calendar td.selected a { color: var(--primary-fg); }

/* ---------- A plain content table on a custom page (memories, PR F) ---------- */
/* Opt-in class: a rounded container, uppercase headers (above) and row dividers. */
table.markit-table {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--markit-radius-panel);
  overflow: hidden;
  margin-bottom: 20px;
}
table.markit-table thead th { background: var(--darkened-bg); border-bottom: 1px solid var(--border-color); padding: 10px 14px; }
table.markit-table td { padding: 10px 14px; border-bottom: 1px solid var(--hairline-color); vertical-align: middle; }
table.markit-table tbody tr:last-child td { border-bottom: none; }
table.markit-table tbody tr:hover { background: var(--selected-bg); }
table.markit-table .button { display: inline-block; white-space: nowrap; margin: 2px 0; }
@media (max-width: 767px) {
  table.markit-table { display: block; max-width: 100%; overflow-x: auto; }
}

/* Agentmail drafts: the draft ID and inbox chip stay on one line; only the
   long recipient addresses wrap to keep the table inside the content width. */
.drafts-table td.draft-id,
.drafts-table .inbox-badge { white-space: nowrap; overflow-wrap: normal; word-break: normal; }
/* Full UUIDs need more than the template's 200px cap. Keep that space inside
   the content width by using a smaller cap for the ellipsized preview. */
.drafts-table td.draft-id { max-width: none; }
.drafts-table td.draft-preview { max-width: 250px; }
