/* ai-kao.com  AI顔印象診断
   デザイントークン：光学測定・レンズコーティング
   ------------------------------------------------ */

:root {
  --paper:      #E7E9EC;
  --paper-hi:   #F1F3F5;
  --paper-deep: #D6DAE0;
  --ink:        #171A21;
  --ink-soft:   #5A6373;
  --ink-faint:  #8A93A2;
  --coat-a:     #B0468A;
  --coat-b:     #3E8E7E;
  /* 文字に乗せる用。淡い紙の上でも読めるところまで落とした版 */
  --coat-a-ink: #7C2A5F;
  --coat-b-ink: #1C5648;
  --line:       rgba(23, 26, 33, 0.14);
  --line-soft:  rgba(23, 26, 33, 0.07);

  --font-display: "Shippori Mincho B1", "Hiragino Mincho ProN", serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;

  --wrap: 34rem;
  --r: 2px;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.85;
  letter-spacing: 0.02em;
  overflow-x: hidden;
}

/* 紙の質感：極細のグリッド */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.5;
}

.wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

a { color: inherit; }

/* ---------- ヘッダー ---------- */

.site-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.site-head__mark {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.site-head__note {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

/* ---------- ヒーロー ---------- */

.hero {
  position: relative;
  padding-top: 34px;
  padding-bottom: 40px;
  text-align: center;
}

.hero__canvas-slot {
  position: relative;
  width: 208px;
  height: 246px;
  margin: 0 auto 22px;
}

#heroMesh { width: 100%; height: 100%; display: block; }

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

.hero__title {
  font-family: var(--font-display);
  font-size: clamp(28px, 8.4vw, 38px);
  font-weight: 600;
  line-height: 1.34;
  letter-spacing: 0.01em;
  margin: 0 0 14px;
}

.hero__title em {
  font-style: normal;
  background: linear-gradient(105deg, var(--coat-a-ink), var(--coat-b-ink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lede {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 auto 26px;
  max-width: 26rem;
}

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

.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--r);
  background: var(--ink);
  color: var(--paper-hi);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  min-height: 50px;
  font-size: 14px;
  font-weight: 500;
}

.btn__code {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  opacity: 0.55;
}

.hero__note {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin: 14px 0 0;
  line-height: 1.7;
}

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

/* ---------- セクション ---------- */

.sec { padding: 40px 0; border-top: 1px solid var(--line); }

.sec__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  margin: 0 0 10px;
}

.sec__title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.5;
  margin: 0 0 18px;
}

.sec p { font-size: 14px; color: var(--ink-soft); }

/* ---------- 軸の説明 ---------- */

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

.axis-row {
  display: grid;
  grid-template-columns: 4.6rem 1fr;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}

.axis-row__key {
  font-family: var(--font-mono);
  font-size: 14px;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding-top: 2px;
}

.axis-row__name { font-size: 14.5px; font-weight: 500; margin: 0 0 2px; }
.axis-row__desc { font-size: 12.5px; color: var(--ink-soft); margin: 0; line-height: 1.7; }

/* ---------- 計測票（署名要素） ---------- */

.chart { margin: 0; padding: 0; border: 0; }

.chart__row { padding: 15px 0 17px; border-bottom: 1px solid var(--line-soft); }

.chart__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin-bottom: 11px;
}

.chart__head b { color: var(--ink); font-size: 12px; }

.chart__track {
  position: relative;
  height: 22px;
}

/* 目盛り */
.chart__ticks {
  position: absolute;
  inset: auto 0 0;
  height: 9px;
  background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 10% 100%;
  border-bottom: 1px solid var(--line);
}

.chart__center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.chart__marker {
  position: absolute;
  top: 1px;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--coat-a), var(--coat-b));
  box-shadow: 0 0 0 3px var(--paper);
  left: 50%;
  transition: left 1.05s cubic-bezier(0.22, 1.4, 0.36, 1);
}

.chart__value {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  text-align: right;
  margin-top: 5px;
}

/* ---------- 診断フロー ---------- */

.stage { display: none; }
.stage.is-active { display: block; }

.shot {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-width: 320px;
  margin: 0 auto 20px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  overflow: hidden;
}

.shot canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}


.scan-note {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  text-align: center;
  min-height: 1.6em;
}

.scan-note::after {
  content: "";
  animation: dots 1.4s steps(4, end) infinite;
}

@keyframes dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

.err {
  border: 1px solid var(--coat-a);
  padding: 14px 16px;
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
}

.err b { display: block; margin-bottom: 4px; font-size: 13.5px; }

/* ---------- 結果 ---------- */

.result-card {
  position: relative;
  padding: 30px 22px 26px;
  background: var(--paper-hi);
  border: 1px solid var(--line);
  overflow: hidden;
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--coat-a), var(--coat-b), var(--coat-a));
}

.result-card__code {
  font-family: var(--font-mono);
  font-size: clamp(44px, 15vw, 64px);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.05;
  margin: 0 0 12px;
  /* グラデーションが読めない環境では単色で表示される */
  color: var(--ink);
  background: linear-gradient(115deg, var(--coat-a-ink), var(--coat-b-ink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-card__name {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  margin: 0 0 6px;
}

.result-card__tag { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 20px; }

.rarity {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  padding: 5px 11px;
}

.rarity b { font-size: 15px; color: var(--ink); }

.result-body { margin-top: 30px; }
.result-body h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 30px 0 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.result-body p { font-size: 14px; line-height: 1.9; }

.suit { list-style: none; margin: 0; padding: 0; }
.suit li {
  display: grid;
  grid-template-columns: 5.2rem 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.suit dt, .suit li > span:first-child {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  padding-top: 4px;
}

.kw { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 0; padding: 0; list-style: none; }
.kw li {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

/* ---------- タイプ一覧 ---------- */

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.type-cell {
  background: var(--paper);
  padding: 15px 13px;
  text-decoration: none;
  display: block;
  transition: background 0.18s ease;
}

.type-cell:hover, .type-cell:focus { background: var(--paper-hi); }

.type-cell__code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 4px;
}

.type-cell__name {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  display: block;
  margin-bottom: 3px;
}

.type-cell__tag {
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.6;
  display: block;
}

.type-cell.is-current { background: var(--paper-deep); }

/* ---------- 相性 ---------- */

.match-score {
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(115deg, var(--coat-a-ink), var(--coat-b-ink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0 0 8px;
}

.match-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  text-align: center;
  margin: 0 0 22px;
}

.match-pair__x { font-family: var(--font-mono); color: var(--ink-faint); font-size: 13px; }
.match-pair a { text-decoration: none; }
.match-pair__code {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  display: block;
}
.match-pair__name { font-family: var(--font-display); font-size: 13.5px; display: block; }

/* ---------- FAQ ---------- */

.faq { border-top: 1px solid var(--line-soft); }
.faq summary {
  padding: 15px 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--font-mono); color: var(--ink-faint); }
.faq[open] summary::after { content: "−"; }
.faq p { padding: 4px 0 16px; margin: 0; font-size: 13px; border-bottom: 1px solid var(--line-soft); }

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

.site-foot {
  border-top: 1px solid var(--line);
  padding: 26px 20px 40px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.site-foot nav { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-bottom: 14px; }
.site-foot a { font-size: 12.5px; color: var(--ink-soft); }
.site-foot small { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; color: var(--ink-faint); }

.crumb {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding: 14px 0 0;
}
.crumb a { text-decoration: none; }

.prose h2 { font-family: var(--font-display); font-size: 17px; margin: 28px 0 8px; }
.prose p, .prose li { font-size: 13.5px; color: var(--ink-soft); line-height: 1.9; }

/* ---------- 広く見せる（タブレット以上） ---------- */

@media (min-width: 720px) {
  body { font-size: 16px; }
  :root { --wrap: 40rem; }
  .type-grid { grid-template-columns: repeat(4, 1fr); }
  .hero { padding-top: 52px; padding-bottom: 56px; }
}

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

/* ---------- 撮影／画像選択 ---------- */

.pick { display: grid; gap: 10px; }

/* ---------- カメラ ---------- */

.cam {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0E1016;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px;
}

.cam[hidden] { display: none; }

.cam__frame {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #000;
}

.cam__frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);   /* 鏡像で見せる。保存時は元に戻す */
  display: block;
}

/* 顔を合わせるための目安。実際の判定には使わない */
.cam__guide {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 58%;
  aspect-ratio: 4 / 5;
  transform: translate(-50%, -50%);
  border: 1px dashed rgba(241, 243, 245, 0.5);
  border-radius: 50% / 46%;
  pointer-events: none;
}

.cam__hint {
  color: rgba(241, 243, 245, 0.72);
  font-size: 12.5px;
  margin: 0;
  text-align: center;
}

.cam__bar {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.cam__bar .btn--ghost {
  color: rgba(241, 243, 245, 0.86);
  border-color: rgba(241, 243, 245, 0.28);
}

.cam__bar .btn:not(.btn--ghost) {
  background: var(--paper-hi);
  color: var(--ink);
}

/* ---------- 4文字コードの書体 ---------- */
/* Space Mono は W と M の判別がつきにくかったため、
   コード表示だけ字面の広い Montserrat に分けている。 */

:root { --font-code: "Montserrat", "Zen Kaku Gothic New", sans-serif; }

.result-card__code,
.type-cell__code,
.match-pair__code,
.match-score,
.rarity b {
  font-family: var(--font-code);
  font-weight: 800;
}

.result-card__code { letter-spacing: 0.10em; }
.type-cell__code   { letter-spacing: 0.08em; font-weight: 700; }
.match-pair__code  { letter-spacing: 0.06em; font-weight: 700; }

/* ---------- 軸の説明：名前と説明文の間隔 ---------- */

.axis-row__name {
  display: block;
  margin-bottom: 6px;
}

.axis-row__desc { display: block; }

/* ---------- 較正モード ---------- */

.debug {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  white-space: pre;
  overflow-x: auto;
  padding: 12px 14px;
  margin: 4px 0 0;
  border: 1px dashed var(--line);
  color: var(--ink-soft);
}

/* ---------- 較正ツール（運営用） ---------- */

.cal-table {
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 10.5px;
  width: 100%;
  min-width: 34rem;
}
.cal-table th, .cal-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
}
.cal-table th { color: var(--ink-faint); text-align: right; }
.cal-table th:first-child, .cal-table td:first-child { text-align: left; }

/* ---------- タイプアイコン ---------- */
/* 形そのものが4軸の値から決まる。丸み＝C/L、目の高さ＝Y/M、
   目の間隔＝N/W、縦横比＝V/H。 */

.result-card.has-glyph { padding-right: 128px; }

.result-card__glyph {
  position: absolute;
  top: 26px;
  right: 20px;
  width: 96px;
  line-height: 0;
}

.result-card__glyph svg { width: 100%; height: auto; }

.type-cell__glyph {
  display: block;
  width: 46px;
  margin: 0 0 8px;
  line-height: 0;
}

.type-cell__glyph svg { width: 100%; height: auto; }

.match-pair__glyph {
  display: block;
  width: 44px;
  margin: 0 auto 6px;
  line-height: 0;
}

.match-pair__glyph svg { width: 100%; height: auto; }

@media (min-width: 720px) {
  .result-card.has-glyph { padding-right: 168px; }
  .result-card__glyph { width: 124px; right: 26px; }
}

/* 幅の狭い端末ではアイコンを小さくして文字の折り返しを防ぐ */
@media (max-width: 359px) {
  .result-card.has-glyph { padding-right: 96px; }
  .result-card__glyph { width: 76px; }
}
