/* Squarewell dashboard chrome: brand tokens, base elements and shared
   components, taken from the landing page (landing-page/public/styles.css)
   and marketing/brand-kit.md. Spec: plans/36-dashboard-theme.md.

   Owner surfaces only. Never load this in a customer page, a preview
   frame or the published-site platform CSS (ADR-021).

   Layer names match manage.css, so the two sheets share layers. Load this
   file first: manage.css, editor.css and assistant.css win ties in the
   same layer, and customizer.css (cz.* layers) sits above them all. */
@layer reset, tokens, base, layout, components, utilities;

/* Fonts are self-hosted: the dashboard CSP is default-src 'self', which
   blocks Google Fonts. Files sit next to this sheet in fonts/. */
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/barlow-condensed-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("fonts/barlow-condensed-latin-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@layer tokens {
  :root {
    color-scheme: light dark;

    /* Brand (fixed in both schemes) */
    --sw-ink: #141414;
    --sw-cobalt: #1F4FD8;
    --sw-cobalt-light: #5B82F0;
    --sw-yellow: #FFC629;
    --sw-white: #FFFFFF;
    --sw-paper: #F6F5F1;

    /* Neutrals (light) */
    --sw-bg: var(--sw-paper);
    --sw-surface: #FFFFFF;
    --sw-surface-2: #EFEDE7;   /* quiet fill: hovered rows, segmented tracks */
    --sw-text: var(--sw-ink);
    --sw-muted: #4A4A4A;       /* 8.1:1 on paper */
    --sw-faint: #66645E;       /* 5.4:1 on paper, meta text only */
    --sw-line: #D6D3CA;        /* hairlines, decorative */
    --sw-rule: var(--sw-text); /* the heavy ink rules and borders */
    --sw-slab: var(--sw-ink);  /* always-dark bars */
    --sw-grid: rgb(20 20 20 / 0.06);

    /* Action */
    --sw-link: var(--sw-cobalt);
    --sw-primary: var(--sw-cobalt);
    --sw-primary-ink: var(--sw-white);
    --sw-primary-edge: var(--sw-ink);
    --sw-primary-soft: #E6ECFB;
    --sw-highlight: var(--sw-yellow);
    --sw-highlight-ink: var(--sw-ink);

    /* Status: text color and a tint to sit it on (each pair is 5.5:1 or better) */
    --sw-ok: #146C2E;    --sw-ok-bg: #E5F1E8;
    --sw-warn: #8A5300;  --sw-warn-bg: #FFF4D6;
    --sw-err: #B42318;   --sw-err-bg: #FBEAE8;

    /* Type */
    --sw-font-head: "Barlow Condensed", "Arial Narrow", sans-serif;
    --sw-font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    --sw-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sw-t-display: clamp(2.25rem, 5vw, 3.5rem); /* sign-in, empty states */
    --sw-t-h1: clamp(1.875rem, 3.5vw, 2.5rem);   /* page and site titles */
    --sw-t-h2: 1.5rem;                           /* card and section heads */
    --sw-t-h3: 1.125rem;
    --sw-t-body: 1rem;
    --sw-t-small: 0.875rem;
    --sw-t-tag: 0.75rem;
    --sw-track-tag: 0.14em;   /* ALL CAPS Inter labels */
    --sw-track-head: -0.005em;

    /* Space: 4/8 rhythm, the landing scale */
    --sw-s1: 4px;  --sw-s2: 8px;  --sw-s3: 16px; --sw-s4: 24px;
    --sw-s5: 40px; --sw-s6: 64px; --sw-s7: 96px;

    /* Shape: square everything. Only device mockups get a radius. */
    --sw-radius: 0;
    --sw-radius-device: 28px;
    --sw-border: 2px;         /* controls, tickets */
    --sw-rule-heavy: 4px;     /* section and card top rules */

    /* Depth: no soft shadows at rest. A hard ink lip on lift, and a
       soft drop only for things that float over the preview. */
    --sw-lift: 0 3px 0 var(--sw-ink);
    --sw-float: 0 3px 0 var(--sw-ink), 0 16px 32px rgb(20 20 20 / 0.16);

    /* Focus: ink outline plus a yellow ring, as on the landing page */
    --sw-focus-outline: 3px solid var(--sw-text);
    --sw-focus-ring: 0 0 0 3px var(--sw-yellow);

    /* Motion */
    --sw-fast: 120ms;
    --sw-ease-out: cubic-bezier(.2, .7, .2, 1);

    /* Sizes */
    --sw-control: 44px;
    --sw-control-sm: 36px;
    --sw-page: 76rem;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --sw-bg: #1C1C1A;
      --sw-surface: #242422;
      --sw-surface-2: #2C2C29;
      --sw-text: #F2F2F2;
      --sw-muted: #B8B8B8;
      --sw-faint: #8E8E88;
      --sw-line: #3A3A36;
      --sw-slab: #0A0A0A;
      --sw-grid: rgb(255 255 255 / 0.045);
      --sw-link: #7D9BFF;   /* 5:1 or better on every dark surface */
      --sw-primary-edge: var(--sw-cobalt-light);
      --sw-primary-soft: #23304F;
      --sw-ok: #7BD88F;   --sw-ok-bg: #1E3324;
      --sw-warn: #FFC629; --sw-warn-bg: #3A3220;
      --sw-err: #FF8A80;  --sw-err-bg: #3D2321;
      --sw-lift: 0 3px 0 #000;
      --sw-float: 0 3px 0 #000, 0 16px 32px rgb(0 0 0 / 0.5);
    }
  }

  /* Always-dark pieces (top bar, toasts), in both schemes */
  .sw-dark {
    --sw-bg: var(--sw-slab);
    --sw-surface: #1B1B1B;
    --sw-text: #F2F2F2;
    --sw-muted: #B8B8B8;
    --sw-faint: #8E8E88;
    --sw-line: #333333;
    --sw-link: var(--sw-cobalt-light);
    --sw-primary-edge: var(--sw-cobalt-light);
    background: var(--sw-bg);
    color: var(--sw-text);
  }

  /* Bridge: the names manage.css, editor.css and assistant.css already
     use. They take effect once manage.css drops its own tokens block. */
  :root {
    --font: var(--sw-font-body);
    --mono: var(--sw-font-mono);
    --bg: var(--sw-bg);
    --surface: var(--sw-surface);
    --surface-2: var(--sw-surface-2);
    --line: var(--sw-line);
    --line-strong: var(--sw-rule);
    --text: var(--sw-text);
    --text-2: var(--sw-muted);
    --text-3: var(--sw-faint);
    --accent: var(--sw-primary);
    --accent-ink: var(--sw-primary-ink);
    --accent-soft: var(--sw-primary-soft);
    --focus: var(--sw-text);
    --ok: var(--sw-ok);       --ok-bg: var(--sw-ok-bg);
    --warn: var(--sw-warn);   --warn-bg: var(--sw-warn-bg);
    --danger: var(--sw-err);  --danger-bg: var(--sw-err-bg);
    --muted-bg: var(--sw-surface-2);
    --r-sm: var(--sw-radius);
    --r: var(--sw-radius);
    --r-lg: var(--sw-radius);
    --shadow: none;
    --shadow-pop: var(--sw-float);
    --s1: var(--sw-s1); --s2: var(--sw-s2); --s3: 12px; --s4: var(--sw-s3);
    --s5: var(--sw-s4); --s6: 32px; --s7: 48px; --s8: var(--sw-s6);
    --page: var(--sw-page);
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
  input, button, select, textarea { font: inherit; color: inherit; }
}

@layer base {
  html { -webkit-text-size-adjust: 100%; }
  body {
    background: var(--sw-bg);
    color: var(--sw-text);
    font-family: var(--sw-font-body);
    font-size: var(--sw-t-body);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-block-size: 100vh;
  }
  /* Barlow Condensed, ALL CAPS, tight. Headlines only, a few words. */
  h1, h2, .sw-head {
    font-family: var(--sw-font-head);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: var(--sw-track-head);
    text-transform: uppercase;
  }
  h1 { font-size: var(--sw-t-h1); }
  h2 { font-size: var(--sw-t-h2); font-weight: 700; line-height: 1; }
  /* h3 stays Inter: it labels form groups and list items, often long */
  h3 { font-family: var(--sw-font-body); font-size: var(--sw-t-h3); font-weight: 600; line-height: 1.3; }
  a { color: var(--sw-link); text-underline-offset: 0.18em; }
  a:hover { text-decoration-thickness: 2px; }
  strong, b { font-weight: 600; }
  small { font-size: var(--sw-t-small); }
  code, .mono { font-family: var(--sw-font-mono); font-size: 0.875em; }
  ::selection { background: var(--sw-yellow); color: var(--sw-ink); }
  :focus-visible {
    outline: var(--sw-focus-outline);
    outline-offset: 3px;
    box-shadow: var(--sw-focus-ring);
    border-radius: 0;
  }
}

@layer components {
  /* Buttons. Inter 600, never Barlow. Square, 2px edge, lift on hover. */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sw-s2);
    min-block-size: var(--sw-control);
    padding: 0 var(--sw-s4);
    font: inherit; font-size: 0.9375rem; font-weight: 600; line-height: 1.2;
    white-space: nowrap; text-decoration: none; cursor: pointer;
    border: var(--sw-border) solid var(--sw-text);
    border-radius: var(--sw-radius);
    background: var(--sw-surface);
    color: var(--sw-text);
    transition: translate var(--sw-fast), box-shadow var(--sw-fast), background-color var(--sw-fast);
  }
  .btn:hover { translate: 0 -2px; box-shadow: var(--sw-lift); text-decoration: none; }
  .btn:active { translate: 0 0; box-shadow: none; }
  .btn:focus-visible { box-shadow: var(--sw-focus-ring); }
  .btn--primary { background: var(--sw-primary); color: var(--sw-primary-ink); border-color: var(--sw-primary-edge); }
  .btn--secondary { background: var(--sw-surface); color: var(--sw-text); border-color: var(--sw-text); }
  .btn--danger { background: var(--sw-err); color: var(--sw-white); border-color: var(--sw-ink); }
  @media (prefers-color-scheme: dark) {
    .btn--danger { background: #B42318; border-color: var(--sw-err); }
  }
  /* Quiet: a text button, like the landing footer's link button */
  .btn--quiet {
    border-color: transparent; background: transparent; color: var(--sw-muted);
    font-weight: 500; padding-inline: var(--sw-s2);
    text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 0.18em;
  }
  .btn--quiet:hover { translate: none; box-shadow: none; color: var(--sw-text); text-decoration-color: currentColor; }
  .btn--sm { min-block-size: var(--sw-control-sm); padding-inline: var(--sw-s3); font-size: var(--sw-t-small); }
  .btn[disabled], .btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; translate: none; box-shadow: none; }
  .btn[aria-busy="true"] { cursor: progress; }

  /* Inputs: paper fill, 2px ink edge, square */
  :where(input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
         input[type="time"], input[type="url"], input[type="search"], input:not([type]), select, textarea) {
    inline-size: 100%;
    min-block-size: var(--sw-control);
    padding: 0.5rem 12px;
    border: var(--sw-border) solid var(--sw-text);
    border-radius: var(--sw-radius);
    background: var(--sw-bg);
    color: var(--sw-text);
  }
  :where(input, select, textarea)::placeholder { color: var(--sw-faint); opacity: 1; }
  /* The yellow ring hugs the field and the ink outline sits outside it,
     as on the landing. At offset 0 the outline hid the ring. */
  :where(input, select, textarea):focus-visible { outline: var(--sw-focus-outline); outline-offset: 3px; box-shadow: var(--sw-focus-ring); }
  :where(input, select, textarea)[aria-invalid="true"] { border-color: var(--sw-err); }
  :where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--sw-primary); inline-size: 1.125rem; block-size: 1.125rem; }

  /* Labels: Inter 600 for fields. ALL CAPS tracked for kickers. */
  .kicker {
    font-family: var(--sw-font-body);
    font-size: var(--sw-t-tag); font-weight: 600; line-height: 1;
    letter-spacing: var(--sw-track-tag); text-transform: uppercase;
    color: var(--sw-muted);
  }
  /* Stamp: the landing's inverted section label */
  .stamp {
    display: inline-block;
    font-size: var(--sw-t-tag); font-weight: 600; line-height: 1;
    letter-spacing: var(--sw-track-tag); text-transform: uppercase;
    background: var(--sw-text); color: var(--sw-bg);
    padding: 9px 12px 7px;
  }

  /* Status chips: square, ALL CAPS, a square bullet */
  .chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 8px 3px;
    font-size: 0.6875rem; font-weight: 600; line-height: 1.2;
    letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
    border-radius: var(--sw-radius);
    background: var(--sw-surface-2); color: var(--sw-muted);
  }
  .chip::before { content: ""; flex: none; inline-size: 7px; block-size: 7px; background: currentColor; }
  .chip--plain::before { display: none; }
  .chip--live, .chip--ok { background: var(--sw-ok-bg); color: var(--sw-ok); }
  .chip--draft, .chip--warn { background: var(--sw-highlight); color: var(--sw-highlight-ink); }
  .chip--err { background: var(--sw-err-bg); color: var(--sw-err); }
  .chip--lead { background: var(--sw-primary-soft); color: var(--sw-link); }

  /* Cards: white sheet, hairline sides, 4px ink rule on top */
  .card {
    background: var(--sw-surface);
    border: 1px solid var(--sw-line);
    border-block-start: var(--sw-rule-heavy) solid var(--sw-rule);
    border-radius: var(--sw-radius);
    box-shadow: none;
    padding: var(--sw-s4);
  }
  /* Ticket: the one primary form on a page. Full 2px ink box and a
     yellow tag hung on its top edge. */
  .ticket {
    position: relative;
    background: var(--sw-surface);
    border: var(--sw-border) solid var(--sw-text);
    border-radius: var(--sw-radius);
    padding: var(--sw-s5) var(--sw-s4) var(--sw-s4);
  }
  .ticket__tag {
    position: absolute; inset-block-start: -12px; inset-inline-start: var(--sw-s3);
    margin: 0;
    font-family: var(--sw-font-body);
    font-size: var(--sw-t-tag); font-weight: 600; line-height: 1;
    letter-spacing: var(--sw-track-tag); text-transform: uppercase;
    background: var(--sw-yellow); color: var(--sw-ink);
    padding: 7px 10px 5px;
  }
  .ticket__fine {
    font-size: var(--sw-t-small); color: var(--sw-muted);
    border-block-start: 2px dashed var(--sw-line);
    padding-block-start: var(--sw-s3); margin-block-start: var(--sw-s3);
  }

  /* Yellow marker behind ALL CAPS words. One per screen at most. */
  .hl {
    background: linear-gradient(var(--sw-yellow), var(--sw-yellow)) 0 62% / 100% 0.86em no-repeat;
    color: var(--sw-ink);
    padding-inline: 0.08em; margin-inline: -0.08em;
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
  }

  /* Tape measure: the signature strip. Sign-in and empty states only. */
  .tape {
    block-size: 20px;
    background-color: var(--sw-yellow);
    border-block: 2px solid var(--sw-ink);
    background-image:
      repeating-linear-gradient(90deg, var(--sw-ink) 0 2px, transparent 2px 96px),
      repeating-linear-gradient(90deg, var(--sw-ink) 0 2px, transparent 2px 48px),
      repeating-linear-gradient(90deg, var(--sw-ink) 0 1px, transparent 1px 12px);
    background-size: 100% 100%, 100% 55%, 100% 28%;
    background-repeat: no-repeat;
  }

  /* Blueprint grid: faint 24px grid, faded top and bottom */
  .blueprint { position: relative; isolation: isolate; }
  .blueprint::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image:
      linear-gradient(var(--sw-grid) 1px, transparent 1px),
      linear-gradient(90deg, var(--sw-grid) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 60%, transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 60%, transparent);
  }

  /* Toast: the landing's cookie bar. Inverted, slim, bottom left. */
  .toast {
    position: fixed; z-index: 40;
    inset-block-end: var(--sw-s3); inset-inline-start: var(--sw-s3);
    max-inline-size: min(560px, calc(100vw - 2 * var(--sw-s3)));
    display: flex; align-items: center; gap: var(--sw-s3);
    padding: var(--sw-s2) var(--sw-s2) var(--sw-s2) var(--sw-s3);
    background: var(--sw-text); color: var(--sw-bg);
    font-size: var(--sw-t-small); font-weight: 500; line-height: 1.4;
  }
  .toast[hidden] { display: none; }
  .toast a { color: inherit; }
  .toast .btn { min-block-size: var(--sw-control-sm); border-color: currentColor; background: transparent; color: inherit; }
  .toast .btn--primary { background: var(--sw-yellow); border-color: var(--sw-yellow); color: var(--sw-ink); }
  .toast .btn:hover { translate: 0 -1px; box-shadow: none; }
}

@layer utilities {
  .sr-only { position: absolute; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  @layer components {
    .tape { animation: sw-pull-tape 700ms var(--sw-ease-out) both; }
    @keyframes sw-pull-tape { from { clip-path: inset(0 100% 0 0); } }
  }
}
@media (prefers-reduced-motion: reduce) {
  @layer components {
    .btn { transition: none; }
    .btn:hover { translate: none; }
  }
}
