/* app.css
   Shared styles for すごいシステム2. Palette is defined as CSS custom
   properties on :root so every page (hub + 3 feature pages) stays visually
   consistent with a single source of truth.

   Designed for the target demographic (40-50代 経営者, worried about
   glaucoma / hearing loss / mental sharpness): high contrast, large type
   (18px+ body, 24px+ instructions), big tap targets (56px+ minimum),
   minimal chrome, no tiny icons, no jargon. */

:root {
  color-scheme: light;
  --page: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --ink: #101010;
  --ink-2: #3d3c38;
  --ink-muted: #6b6a63;
  --border: #d8d6cc;
  --accent: #1a5fa8;
  --accent-strong: #0d3f75;
  --accent-contrast: #ffffff;
  --success: #146c3c;
  --success-bg: #e3f3e7;
  --warn: #9a5b00;
  --warn-bg: #fbeed9;
  --danger: #b0221c;
  --danger-bg: #fbe7e5;
  --focus-ring: #d98c00;

  --radius: 16px;
  --radius-sm: 10px;
  --tap-min: 56px;
  --shadow: 0 2px 10px rgba(16, 16, 16, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #121210;
    --surface: #1c1c19;
    --surface-2: #262622;
    --ink: #f7f6f2;
    --ink-2: #d6d4cb;
    --ink-muted: #a4a297;
    --border: #38372f;
    --accent: #5b9bdc;
    --accent-strong: #8cbdec;
    --accent-contrast: #0a1420;
    --success: #6bd394;
    --success-bg: #123322;
    --warn: #e3b34d;
    --warn-bg: #3a2c0e;
    --danger: #ef7a72;
    --danger-bg: #3a1613;
    --focus-ring: #ffb84d;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #121210;
  --surface: #1c1c19;
  --surface-2: #262622;
  --ink: #f7f6f2;
  --ink-2: #d6d4cb;
  --ink-muted: #a4a297;
  --border: #38372f;
  --accent: #5b9bdc;
  --accent-strong: #8cbdec;
  --accent-contrast: #0a1420;
  --success: #6bd394;
  --success-bg: #123322;
  --warn: #e3b34d;
  --warn-bg: #3a2c0e;
  --danger: #ef7a72;
  --danger-bg: #3a1613;
  --focus-ring: #ffb84d;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%; /* 1rem = 18px, set on body below */
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Yu Gothic", "Meiryo", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

h1 {
  font-size: 1.7rem;
  line-height: 1.4;
  margin: 0 0 8px;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.4;
  margin: 0 0 10px;
}

p {
  margin: 0 0 14px;
}

a {
  color: var(--accent);
}

.lead {
  font-size: 1.15rem;
  color: var(--ink-2);
}

/* Instructional text -- the demographic-facing minimum is 24px. */
.instruction {
  font-size: 1.35rem;
  line-height: 1.7;
  color: var(--ink);
}

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

/* -------------------- header -------------------- */

.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap-min);
  padding: 0 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  font-size: 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.back-link:hover {
  border-color: var(--accent);
}

/* -------------------- cards -------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.hub-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 96px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 16px;
}

.hub-card:hover,
.hub-card:focus-visible {
  border-color: var(--accent);
}

.hub-card .badge {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--surface-2);
}

.hub-card .body {
  flex: 1;
}

.hub-card .title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.hub-card .desc {
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.6;
}

/* -------------------- buttons -------------------- */

button,
.btn {
  font-family: inherit;
  font-size: 1.15rem;
  min-height: var(--tap-min);
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 700;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-huge {
  min-height: 84px;
  font-size: 1.4rem;
  border-radius: 24px;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* -------------------- form controls -------------------- */

select,
input[type="range"] {
  font-family: inherit;
  font-size: 1.1rem;
  min-height: var(--tap-min);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.option-row button {
  flex: 1 1 auto;
  min-width: 84px;
}

.option-row button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

/* -------------------- notices -------------------- */

.notice {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 16px;
  font-size: 1.05rem;
  line-height: 1.7;
  border: 1px solid var(--border);
}

.notice-info {
  background: var(--surface-2);
  color: var(--ink);
}

.notice-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn);
}

.notice-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.notice-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}

/* -------------------- result stats -------------------- */

.stat-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.stat {
  flex: 1 1 140px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
}

.stat .value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat .label {
  font-size: 0.95rem;
  color: var(--ink-muted);
  margin-top: 4px;
}

/* -------------------- phrase list -------------------- */

.phrase-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.phrase-list li {
  margin-bottom: 10px;
}

.phrase-item {
  width: 100%;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-size: 1.05rem;
}

.phrase-item[aria-current="true"] {
  border-color: var(--accent);
  border-width: 2px;
}

.phrase-item .lvl {
  flex: none;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-muted);
}

.phrase-item .best {
  flex: none;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* -------------------- ideas board -------------------- */
/* "みんなの声" -- renders GET /api/ideas from the (optional, separate)
   feedback container. See js/ideas-board.js: on any fetch failure this
   section shows a plain muted notice, never an error state, since the
   rest of the site must keep working with the feedback container down. */

.ideas-board {
  margin-top: 8px;
}

.idea-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.idea-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.idea-text {
  margin: 0 0 10px;
  color: var(--ink);
  line-height: 1.7;
}

.idea-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.idea-date {
  font-size: 0.9rem;
}

.idea-upvote {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.idea-upvote:hover:not(:disabled) {
  border-color: var(--accent);
}

.idea-upvote[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.idea-upvote:disabled {
  opacity: 0.7;
  cursor: default;
}

/* -------------------- footer -------------------- */

.feedback-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.feedback-footer a {
  display: flex;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: var(--tap-min);
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
}

/* -------------------- eye-training target/ring -------------------- */

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 420px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
}

.stage .target {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 8px rgba(26, 95, 168, 0.18);
}

.stage .anchor-label {
  position: absolute;
  bottom: 10px;
  font-size: 1rem;
  color: var(--ink-muted);
}

.stage .cue-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
}

.progress-ring-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}

.progress-ring-wrap svg {
  width: 120px;
  height: 120px;
}

.progress-ring-wrap .ring-bg {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 10;
}

.progress-ring-wrap .ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
  transition: stroke-dashoffset 0.2s linear;
}

.progress-ring-wrap .ring-time {
  position: absolute;
  font-size: 1.4rem;
  font-weight: 700;
}

.progress-ring-outer {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* -------------------- reduced motion -------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* In-app manual "reduce motion" toggle (eye-training/app.js), independent
   of the OS-level prefers-reduced-motion setting above -- offered because
   this screen's whole point is on-screen movement, and the target
   demographic should be able to dial that down without changing system
   settings. Also disables the JS-driven continuous animation loop, which
   the CSS media query above cannot reach on its own (see eye-training/app.js). */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* -------------------- responsive -------------------- */

@media (max-width: 420px) {
  body {
    font-size: 17px;
  }
  h1 {
    font-size: 1.5rem;
  }
}

@media (min-width: 720px) {
  body {
    font-size: 19px;
  }
}
