/*
 * P.M.A.トライアングル design tokens — the single source of truth.
 * Every product we build for PMA (desk, ai/* prototypes, finance site, dev tools)
 * reads these variables. Evidence for each value: design/README.md.
 * Contrast of every text pair is checked by: node design/scripts/contrast.mjs
 *
 * Fonts (load once per product; Next.js: next/font/google with variable
 * names --font-noto-sans-jp / --font-cormorant, which the stacks below prefer):
 *   https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&family=Cormorant+Garamond:wght@500;600;700&display=swap
 */

:root {
  /* ---- Brand: the logo's three inks (pma-t.co.jp logo_navy.svg) ---- */
  --pma-navy: #163c7a;        /* the "P" swirl */
  --pma-navy-deep: #041c51;   /* footer slab on pma-t.co.jp subpages */
  --pma-dot: #dd2724;         /* the single red dot — reserved for "your turn" */
  --pma-print-black: #231815; /* logotype; Japanese print K100 rich black */

  /* ---- Surfaces ---- */
  --pma-paper: #ffffff;        /* page */
  --pma-surface: #ffffff;      /* cards, inputs */
  --pma-surface-alt: #f5faff;  /* zebra rows, quiet panels (subpage bg #F5FAFF) */
  --pma-surface-sunk: #f2f2f2; /* wells, disabled fields (home --colorGray) */
  --pma-slab: #041c51;         /* masthead / footer band */
  --pma-on-slab: #ffffff;
  --pma-on-slab-muted: #b8c3d9;

  /* ---- Ink ---- */
  --pma-ink: #231815;          /* body text */
  --pma-ink-2: #3f3a38;        /* secondary text, table cells */
  --pma-ink-muted: #645e5b;    /* captions, meta, placeholders */
  --pma-ink-disabled: #8e8986; /* disabled labels (exempt from AA, still 3:1) */

  /* ---- Rules ---- */
  --pma-rule-strong: #231815;  /* the 1px line under section titles */
  --pma-rule: #c7cfdb;
  --pma-rule-soft: #e4e9f0;
  --pma-rule-input: #7d8698;   /* form-field borders: 3:1 against paper */

  /* ---- Interactive ---- */
  --pma-brand: #163c7a;        /* primary button fill, links */
  --pma-brand-hover: #0e2c5e;
  --pma-on-brand: #ffffff;
  --pma-brand-tint: #e9eff8;   /* selected row, hover wash */
  --pma-link: #163c7a;
  --pma-focus: #2a6ad6;        /* focus ring; differs from navy so it shows on buttons */

  /* ---- Status (chip = fg text on bg tint, mark = dot/icon/left rule) ---- */
  --pma-ok-fg: #0b5d61;        --pma-ok-bg: #e0f2f1;        --pma-ok-mark: #12858a;   /* lagoon */
  --pma-wait-fg: #4a5262;      --pma-wait-bg: #edf0f4;      --pma-wait-mark: #7b8496; /* sand-grey */
  --pma-attn-fg: #6e4800;      --pma-attn-bg: #fff1c7;      --pma-attn-mark: #a87400; /* sun */
  --pma-blocked-fg: #9c1240;   --pma-blocked-bg: #fce6ee;   --pma-blocked-mark: #c81d5a; /* hibiscus */

  /* ---- Ball: whose move is it? ---- */
  --pma-ball-client-mark: #dd2724;  /* filled red dot = 御社の番 (logo dot) */
  --pma-ball-client-fg: #b01e1b;
  --pma-ball-client-bg: #fdeceb;
  --pma-ball-us-mark: #163c7a;      /* navy ring = こちらで進めています */
  --pma-ball-us-fg: #163c7a;
  --pma-ball-us-bg: #e9eff8;

  /* ---- Typography ---- */
  --pma-font-sans: var(--font-noto-sans-jp, "Noto Sans JP"), "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --pma-font-display: var(--font-cormorant, "Cormorant Garamond"), "EB Garamond", Garamond,
    "Hiragino Mincho ProN", "Yu Mincho", serif; /* Latin words and figures only */
  --pma-font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; /* dev tools only */

  /* Bringhurst's scale: 12 14 16 18 21 24 36 48 72 (px at 16px root) */
  --pma-text-xs: 0.75rem;    /* 12 fine print only; never a control label */
  --pma-text-sm: 0.875rem;   /* 14 meta, table headers */
  --pma-text-base: 1rem;     /* 16 body, controls (min for phones) */
  --pma-text-md: 1.125rem;   /* 18 lead, card title */
  --pma-text-lg: 1.3125rem;  /* 21 h3 */
  --pma-text-xl: 1.5rem;     /* 24 h2 */
  --pma-text-2xl: 2.25rem;   /* 36 h1 */
  --pma-text-3xl: 3rem;      /* 48 display (section title, Cormorant) */
  --pma-text-4xl: 4.5rem;    /* 72 display (masthead, Cormorant) */

  --pma-leading-body: 1.85;   /* Japanese running text (home body 1.88) */
  --pma-leading-ui: 1.5;      /* controls, table cells, chips */
  --pma-leading-heading: 1.4;
  --pma-leading-display: 1.05;

  --pma-weight-regular: 400;
  --pma-weight-medium: 500;
  --pma-weight-bold: 700;
  --pma-weight-display: 600;  /* Cormorant section titles (home h2: 600) */

  --pma-tracking-display: 0.02em; /* home h2: 2.74px / 136.9px */
  --pma-tracking-heading: 0.04em;
  --pma-tracking-body: 0.02em;

  --pma-measure: 38em;        /* ~38 full-width chars per line in Japanese */

  /* ---- Space (4px base) ---- */
  --pma-space-1: 0.25rem;
  --pma-space-2: 0.5rem;
  --pma-space-3: 0.75rem;
  --pma-space-4: 1rem;
  --pma-space-5: 1.5rem;
  --pma-space-6: 2rem;
  --pma-space-7: 3rem;
  --pma-space-8: 4rem;
  --pma-space-9: 6rem;
  --pma-gutter: 1rem;         /* phone side gutter; 1.5rem from 768px */
  --pma-page-max: 72rem;
  --pma-tap: 2.75rem;         /* 44px minimum touch target */

  /* ---- Radii: hierarchy, not one value ---- */
  --pma-radius-media: 0;      /* photos, panels, cards: square like a printed page */
  --pma-radius-control: 4px;  /* buttons, inputs (subpage buttons: 4px) */
  --pma-radius-pill: 999px;   /* chips and tags (home WORKS tag) */
  --pma-radius-round: 50%;    /* round icon buttons, ball dots */

  /* ---- Elevation: used only for things that float above the page ---- */
  --pma-shadow-float: 0 1px 2px rgb(4 28 81 / 0.08), 0 8px 24px rgb(4 28 81 / 0.12);
  --pma-shadow-press: inset 0 1px 0 rgb(4 28 81 / 0.12);

  /* ---- Focus ---- */
  --pma-focus-ring: 0 0 0 2px var(--pma-paper), 0 0 0 5px var(--pma-focus);
  --pma-focus-outline: 3px solid var(--pma-focus);

  --pma-ease: cubic-bezier(0.2, 0, 0, 1);
  --pma-duration: 160ms;

  color-scheme: light;
}

/* ---- Dark: the footer slab becomes the page (deep navy, not near-black) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pma-paper: #061633;
    --pma-surface: #0b2046;
    --pma-surface-alt: #0e2652;
    --pma-surface-sunk: #04102a;
    --pma-slab: #020b20;
    --pma-on-slab: #ffffff;
    --pma-on-slab-muted: #a9b6cf;
    --pma-ink: #f1f4f9;
    --pma-ink-2: #d3dae6;
    --pma-ink-muted: #a3b0c6;
    --pma-ink-disabled: #74839e;
    --pma-rule-strong: #e4e9f2;
    --pma-rule: #2c4573;
    --pma-rule-soft: #1a335f;
    --pma-rule-input: #6d82a8;
    --pma-brand: #a9c4f6;
    --pma-brand-hover: #c7d9fa;
    --pma-on-brand: #041c51;
    --pma-brand-tint: #15305f;
    --pma-link: #a9c4f6;
    --pma-focus: #ffd166;
    --pma-ok-fg: #86e0dc;      --pma-ok-bg: #0b3a44;      --pma-ok-mark: #3cc4c2;
    --pma-wait-fg: #c6cdda;    --pma-wait-bg: #1b2d4f;    --pma-wait-mark: #8d9ab2;
    --pma-attn-fg: #ffd77a;    --pma-attn-bg: #3b2f0d;    --pma-attn-mark: #e8ae2c;
    --pma-blocked-fg: #ff9dbd; --pma-blocked-bg: #46122c; --pma-blocked-mark: #ff5c93;
    --pma-ball-client-mark: #ff5a4c;
    --pma-ball-client-fg: #ffa59c;
    --pma-ball-client-bg: #4a1519;
    --pma-ball-us-mark: #a9c4f6;
    --pma-ball-us-fg: #c3d6f9;
    --pma-ball-us-bg: #15305f;
    --pma-shadow-float: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --pma-paper: #061633;
  --pma-surface: #0b2046;
  --pma-surface-alt: #0e2652;
  --pma-surface-sunk: #04102a;
  --pma-slab: #020b20;
  --pma-on-slab: #ffffff;
  --pma-on-slab-muted: #a9b6cf;
  --pma-ink: #f1f4f9;
  --pma-ink-2: #d3dae6;
  --pma-ink-muted: #a3b0c6;
  --pma-ink-disabled: #74839e;
  --pma-rule-strong: #e4e9f2;
  --pma-rule: #2c4573;
  --pma-rule-soft: #1a335f;
  --pma-rule-input: #6d82a8;
  --pma-brand: #a9c4f6;
  --pma-brand-hover: #c7d9fa;
  --pma-on-brand: #041c51;
  --pma-brand-tint: #15305f;
  --pma-link: #a9c4f6;
  --pma-focus: #ffd166;
  --pma-ok-fg: #86e0dc;      --pma-ok-bg: #0b3a44;      --pma-ok-mark: #3cc4c2;
  --pma-wait-fg: #c6cdda;    --pma-wait-bg: #1b2d4f;    --pma-wait-mark: #8d9ab2;
  --pma-attn-fg: #ffd77a;    --pma-attn-bg: #3b2f0d;    --pma-attn-mark: #e8ae2c;
  --pma-blocked-fg: #ff9dbd; --pma-blocked-bg: #46122c; --pma-blocked-mark: #ff5c93;
  --pma-ball-client-mark: #ff5a4c;
  --pma-ball-client-fg: #ffa59c;
  --pma-ball-client-bg: #4a1519;
  --pma-ball-us-mark: #a9c4f6;
  --pma-ball-us-fg: #c3d6f9;
  --pma-ball-us-bg: #15305f;
  --pma-shadow-float: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}

@media (min-width: 768px) {
  :root { --pma-gutter: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --pma-duration: 0ms; }
}
