/* =========================================================
   空撮ガチャ  style.css
   色や大きさは、いちばん上の :root の数字を変えるだけで変わります
   ========================================================= */

:root {
  /* 朝もやの空 */
  --bg: #E8EFF2;
  --card: #FFFFFF;
  --ink: #12232D;
  --ink-2: #4B5F69;
  --line: #C9D7DE;

  --cta: #0A6C78;        /* 「これを見る」のボタン色：湖の青緑 */
  --cta-ink: #FFFFFF;
  --sun: #F2B45B;        /* 「リセマラ」の色：朝日 */
  --sun-ink: #2B1B00;
  --heart: #D6455D;

  --font-serif: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-sans: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1A22;
    --card: #172A35;
    --ink: #E8F1F4;
    --ink-2: #98ADB7;
    --line: #2A4350;
    --cta: #45B8C6;
    --cta-ink: #04222A;
    --heart: #FF7A90;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 20px;
  line-height: 1.6;
  font-weight: 500;
}

button, a { -webkit-tap-highlight-color: transparent; }
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
button:disabled { cursor: default; opacity: .38; }

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

/* ---------- 全体の枠 ---------- */
.app {
  max-width: 1040px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 14px)
    calc(env(safe-area-inset-right, 0px) + 28px)
    calc(env(safe-area-inset-bottom, 0px) + 56px)
    calc(env(safe-area-inset-left, 0px) + 28px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}
.brand {
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: .08em;
  color: var(--ink-2);
}
.mode-label {
  flex: 1;
  text-align: center;
  font-size: 20px;
  color: var(--ink-2);
}

.pill-btn {
  min-height: 52px;
  padding: 0 22px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 19px;
  font-weight: 700;
}
.pill-btn:active { transform: scale(.97); }
.pill-big { min-height: 64px; padding: 0 30px; font-size: 22px; }

.notice {
  margin: 28px 0;
  padding: 22px 26px;
  border-radius: 20px;
  background: var(--card);
  border: 2px solid var(--line);
  font-size: 20px;
}

/* ---------- ホーム ---------- */
.hero {
  margin: 30px 0 22px;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: clamp(46px, 8vw, 76px);
  line-height: 1.12;
  letter-spacing: .02em;
}

.seg-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 0 26px;
}
.seg-label { font-size: 18px; color: var(--ink-2); }
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg-btn {
  min-height: 52px;
  padding: 0 20px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
}
.seg-btn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
  gap: 16px;
}

/* カテゴリのタイル：景色ごとに色が違う（色は categories.json で決まる） */
.tile {
  --tint: rgba(var(--tile-rgb, 100, 120, 140), .20);
  min-height: 138px;
  padding: 18px 20px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  align-items: end;
  text-align: left;
  border: 2px solid rgba(var(--tile-rgb, 100, 120, 140), .42);
  border-radius: 26px;
  background: linear-gradient(var(--tint), var(--tint)), var(--card);
}
.tile:active { transform: scale(.97); }
.tile-emoji { grid-column: 1 / 3; font-size: 46px; line-height: 1; align-self: start; }
.tile-label { font-size: 27px; font-weight: 700; line-height: 1.25; }
.tile-count { font-size: 17px; color: var(--ink-2); padding-bottom: 3px; }

.fav-tile {
  width: 100%;
  min-height: 78px;
  margin-top: 16px;
  padding: 0 24px;
  border: 2px solid var(--heart);
  border-radius: 26px;
  background: transparent;
  font-size: 24px;
  font-weight: 700;
  color: var(--heart);
  text-align: left;
}
.fav-tile:active { transform: scale(.98); }

.linkbtn {
  margin: 22px 0 14px;
  min-height: 52px;
  padding: 0 4px;
  border: 0;
  background: none;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 5px;
}

/* ---------- 結果 ---------- */
.stage { display: grid; gap: 26px; margin-top: 10px; }

.photo {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 30px;
  overflow: hidden;
  background: var(--line);
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;   /* 4:3 の予備サムネイルでも黒帯が切れるようにする */
  display: block;
}
.photo img.loading { opacity: 0; }
.photo.reveal img { animation: reveal .6s cubic-bezier(.2, .7, .2, 1); }
@keyframes reveal {
  from { opacity: 0; transform: scale(1.07); filter: blur(14px); }
  to   { opacity: 1; transform: scale(1);    filter: blur(0); }
}

.badge {
  position: absolute;
  bottom: 16px;
  padding: 3px 14px;
  border-radius: 12px;
  background: rgba(8, 20, 28, .74);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
}
.badge-4k  { left: 16px; }
.badge-dur { right: 16px; }

.info { min-width: 0; }
.v-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: clamp(28px, 4.2vw, 38px);
  line-height: 1.3;
}
.v-place {
  margin: 0 0 12px;
  font-size: 23px;
  font-weight: 700;
}
.chips { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 2px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 17px;
  color: var(--ink-2);
}
.v-note { margin: 0 0 12px; font-size: 17px; color: var(--ink-2); }

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  margin: 20px 0 16px;
  border-radius: 26px;
  background: var(--cta);
  color: var(--cta-ink);
  font-size: 31px;
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
}
.cta:active { transform: scale(.98); }

.actions {
  display: grid;
  grid-template-columns: 1.35fr 1.15fr .8fr;
  gap: 12px;
}
.act {
  min-height: 80px;
  padding: 0 10px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: transparent;
  font-size: 22px;
  font-weight: 700;
  white-space: nowrap;
}
.act:active { transform: scale(.97); }
.act-reroll {
  background: var(--sun);
  border-color: var(--sun);
  color: var(--sun-ink);
}
.act-fav[aria-pressed="true"] {
  border-color: var(--heart);
  color: var(--heart);
  background: transparent;
}
.dice { display: inline-block; }
.dice.spin { animation: spin .6s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { margin-top: 40px; }
.empty p { font-size: 22px; margin: 0 0 24px; }

/* iPad を横向きにしたときは「写真 | 情報とボタン」の2列 */
@media (min-width: 920px) and (orientation: landscape) {
  .stage {
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    align-items: start;
    gap: 34px;
  }
  .cta { min-height: 86px; font-size: 28px; }
  /* 右側は幅がせまいので、リセマラを上段に大きく、♡と×を下段に並べる */
  .actions { grid-template-columns: 1fr 1fr; }
  .act-reroll { grid-column: 1 / 3; }
}

/* ---------- 設定 ---------- */
.page-title {
  margin: 14px 0 8px;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 44px;
}
.section { margin: 38px 0 0; }
.section-title { margin: 0 0 4px; font-size: 24px; font-weight: 700; }
.section-hint { margin: 0 0 14px; font-size: 17px; color: var(--ink-2); }

.row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.row-thumb {
  flex: none;
  width: 136px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  background: var(--line);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 19px; font-weight: 700; line-height: 1.4; }
.row-sub { font-size: 16px; color: var(--ink-2); }
.row-actions { flex: none; display: flex; gap: 10px; }

.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: transparent;
  color: inherit;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}
.btn-small:active { transform: scale(.97); }
.btn-danger { border-color: var(--heart); color: var(--heart); }

.danger-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- お知らせ（トースト） ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: min(92vw, 720px);
  padding: 14px 16px 14px 24px;
  border-radius: 20px;
  background: var(--ink);
  color: var(--bg);
  font-size: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}
.toast-btn {
  flex: none;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: var(--sun);
  color: var(--sun-ink);
  font-size: 18px;
  font-weight: 700;
}

/* iPad を縦にしたときや小さい画面 */
@media (max-width: 700px) {
  body { font-size: 18px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .act-no { grid-column: 1 / 3; }
  .row { flex-wrap: wrap; }
  .row-thumb { width: 112px; }
  .row-actions { width: 100%; }
}

/* 動きが苦手な人向けの設定を尊重 */
@media (prefers-reduced-motion: reduce) {
  .photo.reveal img,
  .dice.spin { animation: none; }
}
