/* Hallmark · pre-emit critique: P4 H4 E4 S5 R4 V4
 * Component: sutra drum · Existing dark/gold theme, ivory reel surface.
 * States: default, hover, focus, active, disabled, loading, error, success.
 */
/* 祈りの車 — Linear ベースライン (ai-workflow/design/linear) を土台に、
   アクセントを経典の域に合う温かみのある金へ調整。 */

:root {
  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;
  --hairline: #23252a;
  --hairline-strong: #34343a;
  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #62666d;
  --accent: #c9a25f;
  --accent-hover: #e0bd85;
  --accent-soft: rgba(201, 162, 95, 0.14);
  --warn: #d68a6a;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --pill: 9999px;
  --font: -apple-system, "SF Pro Display", "Segoe UI", Roboto,
    "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic UI", Meiryo, sans-serif;
  --font-reel: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --reel-paper: #f3eddf;
  --reel-ink: #28231b;
  --reel-metal: #796341;
  --reel-chassis-light: #2d2922;
  --reel-chassis-dark: #151412;
  --reel-edge: rgba(24, 21, 16, 0.84);
  --reel-shade: rgba(24, 21, 16, 0.22);
  --reel-clear: rgba(24, 21, 16, 0);
  --reel-highlight: rgba(255, 253, 245, 0.5);
  --reel-shadow: rgba(0, 0, 0, 0.6);
  --reel-face-height: 40.6px;
  --reel-radius: 310px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.current-reading, .queue-label { color: var(--ink-subtle); font-size: 13px; }
.current-reading { min-height: 2.5em; }
.text-block { position: relative; }
.queue-label b { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.btn { min-height: 44px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.stage[aria-disabled="true"] { opacity: 0.45; cursor: wait; }
.stage { touch-action: manipulation; }
.foot a { color: var(--ink-subtle); }

html, body { margin: 0; overflow-x: clip; }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 24px 56px;
}

/* ---------- Header ---------- */

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--ink-tertiary);
}

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 10px 0 0;
  max-width: 56ch;
  font-size: 14.5px;
  color: var(--ink-subtle);
}

.voice-banner {
  margin: 18px 0 0;
  padding: 10px 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--ink-muted);
}

/* ---------- Layout ---------- */

.grid {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
  gap: 20px;
  margin-top: 28px;
  align-items: start;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ---------- Mechanical sutra drum ---------- */

.drum-heading, .drum-meter { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.drum-heading { margin-bottom: 18px; }
.drum-heading h2 { margin: 0; font-size: 16px; font-weight: 500; color: var(--ink); }
.drum-heading > span { font-size: 12px; color: var(--ink-subtle); }
.stage {
  position: relative;
  width: 100%;
  padding: 14px;
  margin: 0 auto;
  cursor: pointer;
  user-select: none;
  border: 2px solid var(--reel-metal);
  border-radius: 10px;
  background: linear-gradient(var(--reel-chassis-light), var(--reel-chassis-dark));
  box-shadow: inset 0 1px 0 var(--reel-highlight), 0 8px 18px var(--reel-shadow);
  -webkit-tap-highlight-color: transparent;
  transition: border-color 140ms;
}
.stage:hover, .stage.is-hover { border-color: var(--accent-hover); }
.stage:active, .stage.is-active { border-color: var(--accent); }
.stage.is-focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.stage[data-state="loading"] { border-color: var(--ink-subtle); }
.stage[data-state="paused"] { border-color: var(--ink-muted); }
.stage[data-state="error"] { border-color: var(--warn); }
.stage[aria-disabled="true"][data-state="error"] { opacity: 1; cursor: default; }
.stage[data-state="success"] { border-color: var(--accent-hover); }
.reel-window {
  position: relative;
  height: 340px;
  overflow: hidden;
  perspective: 1000px;
  border-radius: 4px;
  background: var(--reel-paper);
  box-shadow: inset 0 0 12px var(--reel-shadow);
}
.reel-window::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--reel-edge), var(--reel-shade) 20%,
    var(--reel-clear) 37%, var(--reel-clear) 63%, var(--reel-shade) 80%, var(--reel-edge));
}
.reel-rotor {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: translateZ(calc(-1 * var(--reel-radius))) rotateX(var(--drum-turn, -7.5deg));
  will-change: transform;
}
.reel-face {
  position: absolute;
  top: 50%;
  left: 8%;
  width: 84%;
  height: var(--reel-face-height);
  margin-top: calc(-0.5 * var(--reel-face-height));
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--reel-ink);
  background: var(--reel-paper);
  font-family: var(--font-reel);
  font-size: clamp(26px, 4vw, 30px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  backface-visibility: hidden;
  transform: rotateX(var(--face-angle)) translateZ(var(--reel-radius));
}
.reel-face.is-selected { font-weight: 700; }
.reel-face.is-intro { font-size: clamp(18px, 2.2vw, 26px); }
.reel-stop-line {
  position: absolute;
  top: 50%;
  left: 14px;
  right: 14px;
  height: var(--reel-face-height);
  transform: translateY(-50%);
  pointer-events: none;
}
.reel-stop-line::before, .reel-stop-line::after {
  content: '';
  position: absolute;
  top: calc(50% - 6px);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
.reel-stop-line::before { left: -10px; border-left: 7px solid var(--accent); }
.reel-stop-line::after { right: -10px; border-right: 7px solid var(--accent); }
.drum-meter { margin-top: 16px; color: var(--ink-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.counter-label { font-size: 12px; color: var(--ink-subtle); }
.counter-label b { margin-left: 6px; color: var(--accent); font-size: 20px; font-weight: 500; }
.drum-selection { font-size: 12px; color: var(--ink-muted); margin: 12px 0 0; }
.reading-heading { font-size: 12px; color: var(--ink-subtle); margin: 24px 0 0; }

.stage-hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-tertiary);
}

/* ---------- Status ---------- */

.statusline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.status-text { color: var(--ink-muted); }

.rounds {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-tertiary);
}

.rounds b { color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-tertiary);
  flex: 0 0 auto;
}

.dot.speaking { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.dot.paused { background: var(--ink-subtle); }
.dot.busy { background: var(--accent-hover); }
.dot.warn { background: var(--warn); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 95, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(201, 162, 95, 0); }
}

/* ---------- Current line & sutra text ---------- */

.current {
  margin: 18px 0;
  min-height: 40px;
  padding-left: 14px;
  border-left: 2px solid var(--accent);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.55;
  color: var(--ink);
}

.text-block {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 8px;
  font-size: 14px;
  line-height: 2;
  color: var(--ink-subtle);
  scrollbar-width: thin;
  scrollbar-color: var(--hairline-strong) transparent;
}

.text-block::-webkit-scrollbar { width: 8px; }
.text-block::-webkit-scrollbar-thumb {
  background: var(--hairline-strong);
  border-radius: var(--pill);
}

.chunk { border-radius: 4px; }

.chunk.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Progress ---------- */

.progress {
  height: 4px;
  margin-top: 18px;
  background: var(--surface-3);
  border-radius: var(--pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 300ms ease;
}

.progress-label {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--ink-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 180px;
  font-size: 12px;
  color: var(--ink-subtle);
}

.field b {
  color: var(--ink-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  background: var(--surface-1);
  color: var(--ink-muted);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 13.5px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-tertiary);
  color: var(--ink);
}

.btn:active { background: var(--surface-3); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #16100a;
  font-weight: 550;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #16100a;
}

select, input[type="range"] { width: 100%; }

select {
  background: var(--surface-1);
  color: var(--ink);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13.5px;
}

input[type="range"] {
  accent-color: var(--accent);
  margin-top: 6px;
}

/* ---------- Focus & footer ---------- */

:is(button, select, input, .stage, .support-link):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.foot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  font-size: 12.5px;
  color: var(--ink-tertiary);
}

.foot p { margin: 0; }
.support { margin-bottom: 18px; }
.support[hidden] { display: none; }
.foot .support-link {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 8px;
  color: var(--accent);
  text-decoration: none;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: normal;
}
.support-external { font-size: 12px; }
.stage-hint, .progress-label, .counter-label, .foot { color: var(--ink-subtle); }

/* ---------- Responsive & motion ---------- */

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .panel { min-width: 0; }
  .stage { width: 100%; }
}

@media (max-width: 414px) {
  .page { padding: 28px 16px 40px; }
  .panel { padding: 18px; }
  .stage { padding: 10px; }
  .reel-stop-line { left: 10px; right: 10px; }
  .btn { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .stage { transition: none; }
  .progress-fill { transition: none; }
  .dot.speaking { animation: none; }
}
