/* ==========================================================================
   藍の濃さをはかる — スタイル

   考え方:
     ・主役は藍の階調そのもの。ページを開いて最初に見えるのは、
       色見本から読み込んだレベル1〜10の帯（ladder）。
     ・色数を増やさない。白い紙の地に藍の濃淡だけを置き、
       唯一の「別の色」は判定した布の色そのもの。
     ・明朝体は数字と見出しに。本文はゴシックで読みやすく。
     ・動きは1か所だけ。結果が出たときに階調の指標が該当レベルへ動く。
   ========================================================================== */

:root {
  /* 和紙の地 */
  --paper: #ffffff;
  --paper-sunk: #f4f2ec;
  --rule: #e3e0d8;

  /* 藍（色見本から取った実測値を基にした段階） */
  --ai-pale: #cfe1f0;
  --ai-mid: #518bbd;
  --ai: #1a528d;
  --ai-deep: #16324d;
  --ai-night: #0d1b36;

  --ink: #1d2a33;
  --ink-soft: #5d6b74;

  --warn: #8c3a2b;

  --step: clamp(0.9rem, 3.2vw, 1.15rem);

  --font-mincho: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-gothic: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-gothic);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   見出し
   -------------------------------------------------------------------------- */

.masthead {
  padding: clamp(2rem, 7vw, 3.2rem) var(--step) 1.2rem;
  max-width: 34rem;
  margin: 0 auto;
}

.masthead__title {
  font-family: var(--font-mincho);
  font-weight: 700;
  /* 和の縦の緊張感を出すため、字間をやや広げる */
  letter-spacing: 0.12em;
  font-size: clamp(1.75rem, 7vw, 2.4rem);
  line-height: 1.35;
  margin: 0;
  color: var(--ai-night);
}

.masthead__lede {
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  max-width: 30rem;
}

/* --------------------------------------------------------------------------
   藍の階調（主役）
   -------------------------------------------------------------------------- */

.ladder {
  padding: 0 var(--step);
  max-width: 34rem;
  margin: 0 auto 1.6rem;
}

.ladder__rail {
  display: flex;
  width: 100%;
  height: clamp(74px, 22vw, 104px);
  border-radius: 3px;
  overflow: hidden;
  background: var(--paper-sunk);
  box-shadow: inset 0 0 0 1px rgba(13, 27, 54, 0.08);
}

.ladder__loading {
  margin: auto;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.rung {
  position: relative;
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
  transition: flex-grow 0.45s cubic-bezier(0.22, 0.9, 0.3, 1);
}

.rung__num {
  font-family: var(--font-mincho);
  font-size: 0.72rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

/* 淡い段は濃い文字、濃い段は白い文字 */
.rung--light .rung__num { color: var(--ai-night); }
.rung--dark .rung__num { color: #fff; }

/* 判定された段。唯一の演出。 */
.rung--marked {
  flex-grow: 2.1;
}

.rung--marked::before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4.5px currentColor;
}

.rung--marked .rung__num {
  opacity: 1;
  font-size: 0.95rem;
  font-weight: 700;
}

.ladder__caption {
  margin: 0.6rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   本体
   -------------------------------------------------------------------------- */

.sheet {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 var(--step) 2rem;
}

.panel { margin-bottom: 1.4rem; }
.panel--center { text-align: center; }

/* --------------------------------------------------------------------------
   ボタン
   -------------------------------------------------------------------------- */

.actions {
  display: grid;
  gap: 0.7rem;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 60px;
  padding: 1rem 1.2rem;
  border: 1px solid transparent;
  border-radius: 2px;
  font-family: var(--font-gothic);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn__icon { width: 1.3em; height: 1.3em; flex: none; }

.btn--primary {
  background: var(--ai-deep);
  color: #fff;
}
.btn--primary:hover { background: var(--ai-night); }

.btn--quiet {
  background: var(--paper);
  color: var(--ai-deep);
  border-color: var(--ai-deep);
}
.btn--quiet:hover { background: var(--paper-sunk); }

.btn:active { transform: translateY(1px); }

.btn:focus-visible {
  outline: 3px solid var(--ai-mid);
  outline-offset: 2px;
}

#btn-again { margin-top: 1.6rem; }

/* --------------------------------------------------------------------------
   補足・コツ・エラー
   -------------------------------------------------------------------------- */

.note {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.tips {
  margin-top: 1.1rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.tips__summary {
  padding: 0.85rem 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ai-deep);
  cursor: pointer;
  list-style: none;
}
.tips__summary::-webkit-details-marker { display: none; }
.tips__summary::before {
  content: "＋";
  margin-right: 0.5em;
  font-family: var(--font-mincho);
}
.tips[open] .tips__summary::before { content: "−"; }

.tips__list {
  margin: 0 0 1rem;
  padding-left: 1.2em;
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.tips__list li { margin-bottom: 0.45rem; }
.tips__list strong { color: var(--ink); }

.alert {
  margin: 1.1rem 0 0;
  padding: 0.85rem 1rem;
  background: #fbf0ed;
  border-left: 3px solid var(--warn);
  color: var(--warn);
  font-size: 0.88rem;
  line-height: 1.65;
}

/* --------------------------------------------------------------------------
   解析中（藍甕に布を沈めるイメージ）
   -------------------------------------------------------------------------- */

.vat {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 2.4rem 0 1.1rem;
}

.vat span {
  width: 9px;
  height: 30px;
  background: var(--ai-pale);
  animation: dip 1.25s ease-in-out infinite;
}
.vat span:nth-child(2) { animation-delay: 0.16s; }
.vat span:nth-child(3) { animation-delay: 0.32s; }

@keyframes dip {
  0%, 100% { background: var(--ai-pale); transform: scaleY(0.7); }
  50% { background: var(--ai-night); transform: scaleY(1); }
}

.working__text {
  margin: 0 0 2.2rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   判定結果
   -------------------------------------------------------------------------- */

.verdict {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--rule);
}

.verdict__level {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

/* 唯一の大胆な要素。色は判定した布の色そのものを当てる。 */
.verdict__num {
  font-family: var(--font-mincho);
  font-weight: 700;
  font-size: clamp(4rem, 19vw, 6rem);
  line-height: 0.82;
  font-variant-numeric: tabular-nums;
  color: var(--ai-night);
}

.verdict__name {
  font-family: var(--font-mincho);
  font-size: clamp(1.05rem, 4.4vw, 1.35rem);
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.compare {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.compare__item dt {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}

.compare__item dd {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.chip {
  width: 30px;
  height: 30px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(13, 27, 54, 0.15);
  flex: none;
}

.compare code {
  font-family: var(--font-gothic);
  font-size: 0.76rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* 指標 */

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.3rem;
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--rule);
}

.metric__label {
  margin: 0 0 0.25rem;
  font-size: 0.74rem;
  color: var(--ink-soft);
}

.metric__value {
  margin: 0;
  font-family: var(--font-mincho);
  font-size: 1.7rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--ai-night);
}

.metric__unit {
  font-family: var(--font-gothic);
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 0.35em;
}

.metric__hint {
  margin: 0.25rem 0 0;
  font-size: 0.73rem;
  color: var(--ink-soft);
}

.meter {
  height: 4px;
  margin-top: 0.5rem;
  background: var(--paper-sunk);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  width: 0;
  background: var(--ai);
  transition: width 0.5s ease-out;
}

/* 判定範囲の可視化 */

.shot {
  margin: 1.3rem 0 0;
}

.shot img {
  display: block;
  width: 100%;
  border-radius: 2px;
}

.shot figcaption {
  margin-top: 0.5rem;
  font-size: 0.76rem;
  color: var(--ink-soft);
}

/* 上位3候補 */

.runners {
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
}

.runners__title {
  margin: 0 0 0.8rem;
  font-family: var(--font-mincho);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--ai-night);
}

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

.runner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
}
.runner:last-child { border-bottom: 0; }

.runner__chip {
  width: 34px;
  height: 34px;
  border-radius: 2px;
  flex: none;
  box-shadow: inset 0 0 0 1px rgba(13, 27, 54, 0.15);
}

.runner__body { flex: 1; min-width: 0; }

.runner__name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.runner__name b {
  font-family: var(--font-mincho);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-right: 0.35em;
}

.runner__delta {
  margin: 0;
  font-size: 0.74rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   フッター
   -------------------------------------------------------------------------- */

.colophon {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.6rem var(--step) 2.6rem;
  border-top: 1px solid var(--rule);
  font-size: 0.74rem;
  line-height: 1.8;
  color: var(--ink-soft);
}
.colophon p { margin: 0 0 0.3rem; }

/* --------------------------------------------------------------------------
   アクセシビリティ
   -------------------------------------------------------------------------- */

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

@media (min-width: 30rem) {
  .actions { grid-template-columns: 1fr 1fr; }
  #btn-again { max-width: 20rem; }
}
