/* EXTRASTAGE E 案「跡の向こう」— 共通の土台（F-6）。土台の持ちもの（ページ群の人は書き換えない）
   色・字・余白は tokens.css の変数だけを使う（生の値を書かない。例外は 2.1 のとおり TOP の円と絵の上の幕だけ）。
   層：reset → base → layout → components（components.css）→ page（各ページの CSS）→ utilities。
   ページの CSS は @layer page { … } の中に書く（土台より強く、!important なしで上書きできる）。 */
@layer reset, base, layout, components, page, utilities;

/* ページをまたぐ切り替え（2.9）：全体を重ねて替える。作品の絵は view-transition-name: art-<slug> で広がる */
@view-transition { navigation: auto; }

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; overflow-x: clip; }
  h1, h2, h3, h4, h5, h6, p, ul, ol, figure, blockquote, dl, dd { margin: 0; padding: 0; }
  ul, ol { list-style: none; }
  img, svg, picture, video { display: block; max-width: 100%; }
  img { height: auto; }
  a { color: inherit; text-decoration: none; }
  a, button, summary { -webkit-tap-highlight-color: transparent; }
  button, input, textarea, select { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; }
  fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
  table { border-collapse: collapse; }
  dialog { color: inherit; }
}

@layer base {
  /* Web の役割の変数（tokens.css の正本の区画の外）。言語ごとに --es-font-sans を替えても、Geologica で組む所
     --es-font-latin：欧文で組む見出し（TOP の英語の行など）／--es-font-num：数字・日時・残り時間（桁のそろう数字と合わせて使う） */
  :root { --hh: 68px; color-scheme: dark; --es-font-latin: "Geologica", var(--es-font-sans); --es-font-num: var(--es-font-latin); }
  @media (max-width: 986px) { :root { --hh: 55px; } }
  /* 暗い地に戻す（明るいページの中のヘッダー・フッター・暗い区画）。tokens.css の暗い画面と同じ役割 */
  [data-es-theme="dark"] {
    --es-bg: var(--es-color-sumi); --es-surface: var(--es-color-keshizumi); --es-text: var(--es-color-kaihaku); --es-text-strong: var(--es-color-hakunetsu);
    --es-text-sub: var(--es-color-hai); --es-border: var(--es-color-nibi); --es-rule: var(--es-color-ibushi); --es-disabled-bg: var(--es-color-ibushi);
    --es-disabled-text: var(--es-color-hai); --es-accent: var(--es-color-subaru); --es-on-accent: var(--es-color-sumi); --es-focus: var(--es-color-subaru);
    color-scheme: dark;
  }
  [data-es-theme="light"] { color-scheme: light; }
  [data-es-theme] { background-color: var(--es-bg); color: var(--es-text); }
  html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--hh) + var(--es-space-21)); }
  body {
    font-family: var(--es-font-sans); font-weight: var(--es-fw-regular);
    font-size: var(--es-text-16); line-height: var(--es-lh-16);
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
    min-height: 100dvh; display: flex; flex-direction: column;
  }
  main { flex: 1 0 auto; outline: none; }
  h1, h2, h3, h4, h5, h6 { font-weight: var(--es-fw-bold); color: var(--es-text-strong); text-wrap: balance; }
  p, li, dd { text-wrap: pretty; }
  /* 和文の本文の折り返し（2026-11-29）：行頭に長音・小書きの仮名・閉じ括弧を置かない（strict）。対応するブラウザ（Chrome）では文節の切れ目で折り返す（auto-phrase）。
     Safari などは auto-phrase を読まず、strict だけが効く（ふつうの和文の折り返し）。見出し（h1〜h6）・名前・ボタンは phrases() の塊で折るので、ここに入れない */
  :lang(ja) :is(p, li, dd, dt, blockquote, figcaption, td) { line-break: strict; word-break: auto-phrase; }
  :focus-visible { outline: var(--es-line-2) solid var(--es-focus); outline-offset: 3px; }
  ::selection { background: var(--es-accent); color: var(--es-on-accent); }
  /* タイ語・ベトナム語：行の高さを 1 段上げる（2.4） */
  .lh-up { --es-lh-13: 2; --es-lh-16: 2.125; --es-lh-21: 2; --es-lh-26: 1.6154; }
  /* 韓国語：語の途中で折り返さない */
  :lang(ko) { word-break: keep-all; }

  /* 字の段階（2.1）。1 つの区画で 4 つまで */
  .t-13 { font-size: var(--es-text-13); line-height: var(--es-lh-13); }
  .t-16 { font-size: var(--es-text-16); line-height: var(--es-lh-16); }
  .t-21 { font-size: var(--es-text-21); line-height: var(--es-lh-21); }
  .t-26 { font-size: var(--es-text-26); line-height: var(--es-lh-26); }
  .t-34 { font-size: var(--es-text-34); line-height: var(--es-lh-34); }
  .t-42 { font-size: var(--es-text-42); line-height: var(--es-lh-42); }
  .t-55 { font-size: var(--es-text-55); line-height: var(--es-lh-55); }
  .t-68 { font-size: var(--es-text-68); line-height: var(--es-lh-68); }
  .t-89 { font-size: var(--es-text-89); line-height: var(--es-lh-89); }
  .b { font-weight: var(--es-fw-bold); } .m { font-weight: var(--es-fw-medium); }
  .sub { color: var(--es-text-sub); } .strong { color: var(--es-text-strong); }
  /* 数字・日時・残り時間：Geologica の桁のそろう数字 */
  .num { font-family: var(--es-font-num); font-variant-numeric: tabular-nums; }
  .mono { font-family: var(--es-font-mono); letter-spacing: var(--es-ls-caps); }
  /* 句読点のあとでだけ折り返す（phrases() が包む）。語の途中で改行しない */
  .w, .kw { display: inline-block; white-space: nowrap; }
  .wd { display: inline-block; white-space: nowrap; }
  /* 本文（words() を .wb で包んだもの。P.words()）：句読点の塊（.w）ごとに折り返す。塊が行より長いときだけ、塊の中を語（.wd）の切れ目で折り返す */
  .wb .w { display: inline-block; white-space: normal; max-width: 100%; }

  .ico { flex: 0 0 auto; }
  .ico--16 { width: var(--es-icon-16); height: var(--es-icon-16); }
  .ico--20 { width: var(--es-icon-20); height: var(--es-icon-20); }
  .ico--24 { width: var(--es-icon-24); height: var(--es-icon-24); }

  .skip { position: absolute; left: var(--es-space-13); top: var(--es-space-13); z-index: 100; padding: var(--es-space-8) var(--es-space-13); background: var(--es-accent); color: var(--es-on-accent); border-radius: var(--es-radius-m); transform: translateY(-200%); }
  .skip:focus { transform: none; }
}

@layer layout {
  /* 幅とグリッド（2.1）：609 まで 3 列・610〜986 5 列・987 から 8 列。外の余白と列の間は tokens.css */
  .wrap { padding-left: max(var(--es-margin), env(safe-area-inset-left)); padding-right: max(var(--es-margin), env(safe-area-inset-right)); }
  .grid { display: grid; grid-template-columns: repeat(var(--es-columns), minmax(0, 1fr)); column-gap: var(--es-gutter); }
  .full { grid-column: 1 / -1; }
  /* 面を 2 つに分ける（3 列と 5 列）。986 までは縦に積む */
  .split { display: grid; grid-template-columns: repeat(var(--es-columns), minmax(0, 1fr)); column-gap: var(--es-gutter); row-gap: var(--es-space-34); }
  .split > * { grid-column: 1 / -1; min-width: 0; }
  @media (min-width: 987px) {
    .split > .split__l { grid-column: 1 / span 3; }
    .split > .split__r { grid-column: 4 / span 5; }
    .split--55 > .split__l { grid-column: 1 / span 5; }
    .split--55 > .split__r { grid-column: 6 / span 3; }
  }
  /* 区画の上下の余白（2.1）：55・89・144。同じ余白を 3 つ続けない */
  .sec { padding-top: var(--es-space-89); padding-bottom: var(--es-space-89); }
  .sec--first { padding-top: var(--es-space-89); }
  .sec--show { padding-top: var(--es-space-144); padding-bottom: var(--es-space-144); }
  .sec--55 { padding-top: var(--es-space-55); padding-bottom: var(--es-space-55); }
  .sec--top0 { padding-top: 0; } .sec--bot0 { padding-bottom: 0; }
  @media (max-width: 609px) {
    .sec { padding-top: var(--es-space-55); padding-bottom: var(--es-space-55); }
    .sec--show { padding-top: var(--es-space-89); padding-bottom: var(--es-space-89); }
  }

  /* 区画の名札（W-5）：DM Mono・13px・大文字・右へ伸びる 1px の線 */
  .label {
    display: flex; align-items: center; gap: var(--es-space-8);
    font-family: var(--es-font-mono); font-size: var(--es-text-13); line-height: var(--es-lh-13);
    font-weight: var(--es-fw-medium); letter-spacing: var(--es-ls-caps); text-transform: uppercase;
    color: var(--es-text-sub); margin-bottom: var(--es-space-13);
  }
  .label::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--es-rule); margin-left: var(--es-space-13); }
  .label--bare::after { display: none; }
  /* 灰白のページ：線の左端に種火の点（線とくっつけ、線の始まりにする） */

  /* 本文の組み（文書・お知らせ・キャンペーンの本文） */
  .prose { max-width: var(--es-measure); color: var(--es-text); }
  .prose > * + * { margin-top: var(--es-space-21); }
  .prose h2 { font-size: var(--es-text-26); line-height: var(--es-lh-26); margin-top: var(--es-space-55); }
  .prose h3 { font-size: var(--es-text-21); line-height: var(--es-lh-21); margin-top: var(--es-space-34); }
  .prose ul { padding-left: 1.2em; list-style: disc; }
  .prose ol { padding-left: 1.4em; list-style: decimal; }
  .prose li + li { margin-top: var(--es-space-8); }
  .prose a { color: var(--es-accent); text-decoration: underline; text-underline-offset: 0.25em; text-decoration-thickness: 1px; }
  .prose table { width: 100%; font-size: var(--es-text-16); }
  .prose th, .prose td { text-align: left; padding: var(--es-space-13) var(--es-space-13) var(--es-space-13) 0; border-bottom: var(--es-line-1) solid var(--es-rule); vertical-align: top; }
  .prose th { font-size: var(--es-text-13); line-height: var(--es-lh-13); font-weight: var(--es-fw-medium); color: var(--es-text-sub); }
  .prose img { border: var(--es-line-1) solid var(--es-border); }
}

@layer utilities {
  .sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

  /* hidden は必ず消す。JavaScript の有無で出し分ける */
  [hidden], [data-slot-off] { display: none !important; }
  html:not(.js) .js-only { display: none !important; }
  .js .nojs-only { display: none !important; }

  /* 試作のログインの状態（2.12）：html[data-auth] と合わない [data-auth] を消す */
  html[data-auth="guest"] [data-auth]:not([data-auth~="guest"]),
  html[data-auth="noname"] [data-auth]:not([data-auth~="noname"]),
  html[data-auth="member"] [data-auth]:not([data-auth~="member"]),
  html[data-auth="creator"] [data-auth]:not([data-auth~="creator"]) { display: none !important; }
  .mt-0 { margin-top: 0 !important; }
  .nowrap { white-space: nowrap !important; }
  .ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .anywhere { overflow-wrap: anywhere; min-width: 0; }
}

/* 動きを減らす設定：ページの切り替えも動かさない（tokens.css が時間を 0 にする） */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
