/* ===========================================================================
   OLIVORA PUBLISHING - CORE DESIGN TOKENS
   Version 1.0  .  Stage 1 deliverable
   ---------------------------------------------------------------------------
   House identity : Deep Navy + Academic Gold, Olive as heritage accent.
   Usage          : Import once at the application root. Every journal theme is
                    produced by overriding ONLY the --j-* journal tokens, which
                    is what jms.JournalDesign.ColorPaletteJson persists (UC-09).
   =========================================================================== */

:root {
  /* ---- 1. HOUSE BRAND ---------------------------------------------------- */
  --ol-navy-900:        #060F1F;   /* deepest - footer base, overlays         */
  --ol-navy-800:        #0B1F3A;   /* PRIMARY - headers, hero, footer         */
  --ol-navy-700:        #14314F;   /* raised navy surfaces                    */
  --ol-navy-600:        #1F4467;   /* navy hover                              */
  --ol-navy-100:        #E3E9F0;   /* navy tint for rules on light            */

  --ol-gold-700:        #866528;   /* gold text on ivory and white: 5.1:1 ivory, 5.4:1 white, 4.8:1 on gold-100 */
  --ol-gold-600:        #C09A4F;   /* gold hover                              */
  --ol-gold-500:        #D4B06A;   /* PRIMARY ACCENT - CTA, rules, numerals   */
  --ol-gold-300:        #E6CF9E;   /* soft gold                               */
  --ol-gold-100:        #F7F1E5;   /* gold tint section background            */

  --ol-olive-800:       #866528;   /* RETIRED -> gold-700. Alias, see note    */
  --ol-olive-600:       #866528;   /* RETIRED -> gold-700                     */
  --ol-olive-300:       #E6CF9E;   /* RETIRED -> gold-300                     */
  --ol-olive-100:       #F7F1E5;   /* RETIRED -> gold-100                     */
  /* The olive family is gone as a colour and kept only as these four aliases,
     so that any stylesheet or page still asking for it gets gold rather than
     a dead variable and an unstyled element. They are not to be used in new
     work; the next person to touch a file using one should replace it. */

  /* ---- 2. NEUTRALS ------------------------------------------------------- */
  --ol-ivory:           #FAF8F5;   /* page background                         */
  --ol-white:           #FFFFFF;   /* cards, article blocks                   */
  --ol-ink:             #222222;   /* body text                               */
  --ol-ink-muted:       #5A6472;   /* metadata, captions                      */
  --ol-ink-faint:       #67707F;   /* timestamps, counters - 5.0:1 on white   */
  --ol-rule:            #E5E1DA;   /* 1px borders on ivory                    */
  --ol-rule-strong:     #CFC8BC;

  /* The edge of a button that has no fill. --ol-rule-strong is a warm hairline
     meant for separating things, and at 1.7:1 against white it divides without
     ever announcing an edge. A control has to announce one: WCAG 1.4.11 asks
     3:1 for the boundary that tells a reader where a button is, which is the
     whole of the complaint when somebody says the buttons are not appearing.
     Both values are measured against their own ground, not guessed. */
  --ol-btn-edge:        #8D96A3;   /* 2.98:1 on #FFFFFF                       */

  /* A panel sitting ON a card: quiet pills, inset boxes, the dashboard's
     stage columns. Ten rules referenced this with a literal fallback and
     nothing ever declared it, so every one of them resolved to the fallback —
     a LIGHT colour, which in dark mode is a pale block carrying pale text.
     Declared in both themes now, and the fallbacks left in place because they
     are harmless once the token exists. */
  --ol-surface-2:       #FAF8F5;

  /* ---- SURFACES THAT ARE NAVY BECAUSE THEY ARE NAVY ---------------------- */
  /*
     --ol-navy-800 does two jobs that pull apart the moment a reader turns on
     dark mode: it is the colour of almost every heading (178 uses) and the
     background of a handful of deliberately dark bands (16). In dark mode the
     headings have to become light and the bands have to stay dark, and one
     token cannot do both.

     So the bands get their own names, fixed in both themes, and
     --ol-navy-800 is free to be what it nearly always is: heading ink.
  */
  --ol-surface-navy:      #0B1F3A;   /* nav bands, callout panels           */
  --ol-surface-navy-deep: #060F1F;   /* utility bar, footer                 */

  /* The journal accent, used as text. --j-primary stays the background
     colour; this is the same hue where it has to be read rather than sat on. */
  --j-primary-ink: var(--j-primary);

  /* ---- 3. STATE: FOUR COLOURS, NOT TEN ----------------------------------- */
  /*
     There used to be a colour per workflow status - ten of them, including a
     purple, a teal and two different oranges - and almost none were used: the
     screens render status as a word. Ten names that have to be kept in step
     with rev.ManuscriptStatus, to tint something nobody tints, is a liability
     rather than a design system.

     Four roles now, drawn only from navy, gold and the neutrals:

       quiet      nothing is happening and nothing is wanted
       active     it is moving through the workflow
       good       it has arrived - accepted, published, confirmed
       attention  it needs a person

     Red is the one hue outside the house palette, and it stays: a failure
     that looks like everything else is a failure nobody sees. Warning and
     danger share it deliberately - the words beside them carry the severity,
     and two reds a shade apart tell a reader nothing.
  */
  --ol-state-quiet:     #67707F;
  --ol-state-active:    #1F4467;
  --ol-state-good:      #866528;
  --ol-state-attention: #A33A3A;

  /* ---- 3b. BORROWED HUES: THE SHARE TILES -------------------------------
     The one deliberate exception to the house palette, and it is contained:
     these are only ever the hover colour of a share tile on an article page.
     A reader scanning that card is looking for a network they recognise, and
     they recognise it by its colour before they read the word beside it, so
     the usual argument for keeping everything navy and gold works against
     the reader here.

     X is the exception to the exception: its mark is black on white and
     white on black, which is what --ol-navy-800 already does in each theme,
     so it borrows that rather than naming a colour of its own.

     Each is a TEXT colour as well as a tint, so each is redefined in dark
     mode — the rule at the top of the dark block, and the reason LinkedIn
     blue is not left at #0A66C2 against a near-black card. */
  --ol-ch-x:    var(--ol-navy-800);
  --ol-ch-li:   #0A66C2;   /* 4.6:1 on white */
  --ol-ch-wa:   #1A7F4B;   /* WhatsApp green darkened from #25D366, which is 1.8:1 */
  --ol-ch-ig:   #BE3080;
  --ol-ch-mail: var(--ol-gold-700);
  --ol-ch-link: var(--ol-navy-600);

  /* The tile a share glyph sits in at rest. Navy on an ivory card, and
     deliberately NOT --ol-surface-navy, which is fixed in both themes: on a
     dark card the fixed navy is #0B1F3A against #171D26, two near-blacks a
     tenth of a step apart, and the six tiles stop being objects and become a
     column of white glyphs floating on nothing. This one lifts in dark mode
     instead. */
  --ol-ch-tile: var(--ol-surface-navy);

  /* Older names, kept pointing at the four above so nothing goes unstyled. */
  --ol-success:         var(--ol-state-good);
  --ol-warning:         var(--ol-state-attention);
  --ol-danger:          var(--ol-state-attention);
  --ol-info:            var(--ol-state-active);

  --ol-status-draft:      var(--ol-state-quiet);
  --ol-status-withdrawn:  var(--ol-state-quiet);
  --ol-status-submitted:  var(--ol-state-active);
  --ol-status-screening:  var(--ol-state-active);
  --ol-status-review:     var(--ol-state-active);
  --ol-status-revision:   var(--ol-state-active);
  --ol-status-typeset:    var(--ol-state-active);
  --ol-status-accepted:   var(--ol-state-good);
  --ol-status-published:  var(--ol-state-good);
  --ol-status-rejected:   var(--ol-state-attention);

  /* ---- 4. TYPOGRAPHY ----------------------------------------------------- */
  --ol-font-display: "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --ol-font-body:    "Inter", "Source Sans Pro", -apple-system, "Segoe UI", sans-serif;
  --ol-font-mono:    "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  /* Print / paper templates only */
  --ol-font-paper-serif: "Source Serif 4", "Charis SIL", "Times New Roman", serif;

  --ol-h1:   clamp(2.25rem, 1.6rem + 2.4vw, 3rem);      /* 36 -> 48px         */
  --ol-h2:   clamp(1.75rem, 1.35rem + 1.5vw, 2.25rem);  /* 28 -> 36px         */
  --ol-h3:   clamp(1.3rem, 1.1rem + 0.8vw, 1.75rem);    /* 21 -> 28px         */
  --ol-h4:   1.125rem;
  --ol-body-lg: 1.125rem;
  --ol-body:    1rem;
  --ol-small:   0.875rem;
  --ol-micro:   0.75rem;

  --ol-leading-tight: 1.2;
  --ol-leading-snug:  1.4;
  --ol-leading-body:  1.65;
  --ol-tracking-caps: 0.08em;

  /* ---- 5. SPACE SCALE (per "08 - Journal design Prompt") ------------------ */
  --ol-xs:  8px;
  --ol-s:  16px;
  --ol-m:  24px;
  --ol-l:  40px;
  --ol-xl: 64px;
  --ol-xxl:96px;

  /* ---- 6. LAYOUT --------------------------------------------------------- */
  --ol-container: 1280px;
  --ol-container-narrow: 820px;   /* article reading measure                  */
  --ol-gutter: 24px;
  --ol-sidebar: 320px;
  /* The sticky white nav bar. Every sticky offset below it derives from
     this, so the bar and the things that park under it cannot drift apart.
     Must match .c-nav .wrap in gateway.css.                               */
  --ol-header-h: 72px;

  /* ---- 7. ELEVATION (minimal, editorial) --------------------------------- */
  --ol-shadow-none: none;
  --ol-shadow-xs: 0 1px 2px rgba(11, 31, 58, .06);
  --ol-shadow-sm: 0 2px 8px rgba(11, 31, 58, .07);
  --ol-shadow-md: 0 8px 24px rgba(11, 31, 58, .10);
  --ol-radius-xs: 3px;
  --ol-radius:    8px;
  --ol-radius-lg: 14px;

  --ol-transition: 160ms cubic-bezier(.4, 0, .2, 1);

  /* ---- 8. PER-JOURNAL THEME SLOTS ---------------------------------------- *
   * Overridden at runtime from jms.JournalDesign.ColorPaletteJson.           *
   * Defaults inherit the Olivora house palette so an unbranded journal       *
   * still ships looking finished.                                            */
  --j-primary:        var(--ol-navy-800);
  --j-primary-dark:   var(--ol-navy-900);
  --j-primary-soft:   var(--ol-navy-100);
  --j-accent:         var(--ol-gold-500);
  --j-accent-text:    var(--ol-gold-700);
  --j-accent-tint:    var(--ol-gold-100);
  --j-surface:        var(--ol-white);
  --j-canvas:         var(--ol-ivory);
  --j-on-primary:     #FFFFFF;
}
/* ---------------------------------------------------------------------------
   PRESET JOURNAL PALETTES  (seeded into jms.ColorPalette)
   Applied as  <body data-journal-palette="slate">

   THREE, NOT SIX. There were six, and three of them - burgundy, olive and
   teal - each brought a whole hue of its own into a house built on navy and
   gold. A publisher whose journals are maroon, green and turquoise does not
   look like a publisher with range; it looks like three unrelated websites
   sharing a footer.

   What is left is one family at three depths, so a journal can feel distinct
   on its own page while still obviously belonging here. Gold is the accent
   throughout, which is what makes them a set.
   --------------------------------------------------------------------------- */
[data-journal-palette="slate"] {
  --j-primary: #2B3240; --j-primary-dark: #1A1F29; --j-primary-soft: #E9EBEF;
  --j-accent: #D4B06A; --j-accent-text: #866528; --j-accent-tint: #F7F1E5;
}
[data-journal-palette="indigo"] {
  --j-primary: #262A5B; --j-primary-dark: #171A3C; --j-primary-soft: #E8E9F2;
  --j-accent: #D4B06A; --j-accent-text: #866528; --j-accent-tint: #F7F1E5;
}

/* The three retired names still resolve, to the house navy, so a journal
   whose stored palette was burgundy renders in brand rather than unstyled
   while somebody decides what it should be. */
[data-journal-palette="olive"],
[data-journal-palette="burgundy"],
[data-journal-palette="teal"],
[data-journal-palette="olivora_navy"] {
  --j-primary: #0B1F3A; --j-primary-dark: #060F1F; --j-primary-soft: #E3E9F0;
  --j-accent: #D4B06A; --j-accent-text: #866528; --j-accent-tint: #F7F1E5;
}

/* ---------------------------------------------------------------------------
   DARK MODE - reader preference only. Journal brand hue is preserved.
   --------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------
   DARK MODE

   WHAT WENT WRONG. The first version flipped the backgrounds and left the
   foregrounds alone. --ol-ivory and --ol-white became near-black, and
   --ol-navy-800 — which is the colour of almost every heading on the site —
   stayed #0B1F3A. On an iPhone with Safari in dark mode the masthead, the
   word "Journals", and every journal title rendered as dark navy on dark
   charcoal and simply vanished. The page was not broken; it was invisible,
   which is worse, because nothing about it looks like a fault.

   The rule this is built on now: a token that is ever used as text must be
   redefined here, in the same place as the surface it sits on. The bands
   that are meant to stay navy in both themes use --ol-surface-navy, which is
   deliberately not listed below.
   --------------------------------------------------------------------------- */
:root { color-scheme: light; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    /* Grounds */
    --ol-ivory:      #10151C;
    --ol-white:      #171D26;
    --j-surface:     #171D26;
    --j-canvas:      #10151C;

    /* Body and metadata */
    --ol-ink:        #E3E9F0;
    --ol-ink-muted:  #A9B4C4;
    --ol-ink-faint:  #8A94A3;

    /* Rules and tints. navy-100 is a pale background in light mode and has
       to become a dark one here, or bordered panels glow. */
    --ol-rule:       #28313D;
    --ol-rule-strong:#3A4553;
    --ol-btn-edge:   #5E6877;   /* 3.3:1 on the dark canvas */
    --ol-surface-2:  #1B222C;   /* a panel raised off the dark card */
    --ol-navy-100:   #28313D;
    --ol-gold-100:   #2A2418;
    --ol-gold-300:   #E6CF9E;

    /* HEADINGS. The whole point. These are ink, not surfaces. */
    --ol-navy-900:   #F2F6FA;
    --ol-navy-800:   #E8EEF6;
    --ol-navy-700:   #C7D3E2;
    --ol-navy-600:   #A9B7C8;
    --j-primary-ink: #E8EEF6;

    /* Gold has to lift off a dark ground to stay readable as text. */
    --ol-gold-700:   #E6CF9E;
    --ol-gold-600:   #D4B06A;

    /* State colours, lifted for contrast on dark. */
    --ol-state-quiet:     #9AA4B2;
    --ol-state-active:    #8FB0D6;
    --ol-state-good:      #E6CF9E;
    --ol-state-attention: #E98B86;

    /* The share tiles. Lifted the same way the state colours are: the
       published brand values are chosen to sit on white and none of the
       three reaches 4.5:1 on a #171D26 card. --ol-ch-x and --ol-ch-mail are
       absent on purpose — they are aliases of tokens already redefined
       above, so they follow the theme without being named twice. */
    --ol-ch-li:   #6EB1F0;
    --ol-ch-wa:   #51D98C;
    --ol-ch-ig:   #F08CC7;

    /* Raised off the card rather than sunk into it: 1.7:1 against the card,
       which is enough for the eye to read six separate objects, and 9.8:1
       for the white glyph inside, which is the number that has to hold. */
    --ol-ch-tile: #3A4553;
  }
}

/* ---------------------------------------------------------------------------
   ACCESSIBILITY FLOOR - do not remove.
   --------------------------------------------------------------------------- */
*:focus-visible {
  outline: 3px solid var(--ol-gold-500);
  outline-offset: 2px;
  border-radius: var(--ol-radius-xs);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
.ol-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ol-skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--ol-gold-500); color: var(--ol-surface-navy-deep);  /* fixed: gold stays gold in both themes, so this ink must too */
  padding: 12px 20px; font-weight: 600;
}
.ol-skip-link:focus { left: 0; }
