/*
 * Prompt Cook のスタイル（docs/DESIGN.md §11）。
 * 色・書体は prompt-note（docs/DESIGN.md §9.2・§9.3）の値をそのまま使う。新しい色は足さない。
 */

:root {
  --pc-bg: #FFFFFF;
  --pc-fg: #111111;
  --pc-muted: #6B7280;
  --pc-border: #E5E7EB;
  --pc-code-bg: #F6F6F7;
  --pc-accent: #2563EB;

  --pc-font-sans: "Inter", "Noto Sans JP", sans-serif;
  --pc-font-mono: "Geist Mono", "Noto Sans JP", ui-monospace, monospace;
  --pc-content-width: 720px;
  --pc-tap: 44px;               /* タップ領域の最小の高さ */
  --pc-bottom-nav-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --pc-bg: #0A0A0A;
    --pc-fg: #EDEDED;
    --pc-muted: #A1A1AA;
    --pc-border: #262626;
    --pc-code-bg: #141414;
    --pc-accent: #60A5FA;
  }
}

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

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

body {
  margin: 0;
  background: var(--pc-bg);
  color: var(--pc-fg);
  font-family: var(--pc-font-sans);
  font-size: 16px;
  line-height: 1.8;
}

a { color: var(--pc-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.4; margin: 0; }

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

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 56px;
  padding: 0 max(20px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--pc-border);
}

.site-header__logo { display: flex; align-items: center; }
.logo { height: 22px; width: auto; display: block; }

.site-nav a {
  font-family: var(--pc-font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pc-muted);
  white-space: nowrap;
}
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--pc-fg); text-decoration: none; }
.site-nav a b { font-weight: 400; color: var(--pc-accent); }

.site-nav--top { display: flex; gap: 24px; }

/* スマホでは、ナビを片手で届く下部に固定する */
.site-nav--bottom { display: none; }

@media (max-width: 640px) {
  .site-nav--top { display: none; }
  .site-nav--bottom {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    justify-content: space-around;
    align-items: stretch;
    height: calc(var(--pc-bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--pc-bg);
    border-top: 1px solid var(--pc-border);
  }
  .site-nav--bottom a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--pc-tap);
  }
  .site-main { padding-bottom: calc(var(--pc-bottom-nav-height) + env(safe-area-inset-bottom) + 24px); }
}

/* ---------------------------------------------------------------- 本文 */

.site-main {
  max-width: var(--pc-content-width);
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.label {
  font-family: var(--pc-font-mono);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--pc-muted);
  margin: 24px 0 12px;
}

.section { padding: 16px 0; border-bottom: 1px solid var(--pc-border); }
.section__title { font-size: 1rem; margin-bottom: 8px; }

.empty { color: var(--pc-muted); padding: 32px 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--pc-border); }

.recipe-list { list-style: none; margin: 0; padding: 0; }
.recipe-list__item { padding: 12px 0; border-bottom: 1px solid var(--pc-border); }

.stack > * + * { margin-top: 16px; }

.notice { padding: 10px 14px; border: 1px solid var(--pc-border); border-radius: 6px; }
.notice--error { border-color: var(--pc-fg); }

/* ---------------------------------------------------------------- フォーム */

.field { display: block; }
.field__label { display: block; font-size: 14px; color: var(--pc-muted); margin-bottom: 4px; }

.input {
  width: 100%;
  min-height: var(--pc-tap);
  padding: 8px 14px;
  font: inherit;
  font-size: 16px; /* iOS で入力時に拡大されないよう 16px 以上にする */
  color: var(--pc-fg);
  background: var(--pc-code-bg);
  border: 1px solid var(--pc-border);
  border-radius: 8px;
}
.input:focus { outline: 2px solid var(--pc-accent); outline-offset: -1px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--pc-tap);
  padding: 0 20px;
  font: inherit;
  font-size: 15px;
  color: var(--pc-fg);
  background: transparent;
  border: 1px solid var(--pc-border);
  border-radius: 8px;
  cursor: pointer;
}
.button:hover { border-color: var(--pc-fg); }
.button--primary { color: var(--pc-bg); background: var(--pc-accent); border-color: var(--pc-accent); }
.button--primary:hover { opacity: 0.9; }

.search { margin-bottom: 8px; }

/* ---------------------------------------------------------------- ログイン */

.login { max-width: 420px; margin: 8vh auto 0; }
.login .button { width: 100%; }

/* ---------------------------------------------------------------- レシピ一覧 */

.list-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.button--small { min-height: 36px; padding: 0 14px; font-size: 14px; }

.recipe-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--pc-border);
  color: inherit;
}
.recipe-card:hover { text-decoration: none; }
.recipe-card:hover .recipe-card__title { color: var(--pc-accent); }

.recipe-card__thumb {
  flex: none;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--pc-code-bg);
}
.recipe-card__thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pc-font-mono);
  font-size: 10px;
  color: var(--pc-muted);
}

.recipe-card__body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.recipe-card__title { font-weight: 700; line-height: 1.5; }
.recipe-card__summary {
  font-size: 13px;
  line-height: 1.6;
  color: var(--pc-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------------------------------------------------------------- レシピ */

.recipe__image {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 16px;
  background: var(--pc-code-bg);
}
.recipe__meta { font-family: var(--pc-font-mono); font-size: 13px; color: var(--pc-muted); margin: 0 0 4px; }
.recipe__title { font-size: 1.5rem; }
.recipe__description { color: var(--pc-muted); font-size: 15px; }
.recipe__section { margin-top: 24px; }
.recipe__yield { color: var(--pc-fg); margin-left: 8px; }

.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients__item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--pc-border);
}
.ingredients__item--grouped { padding-left: 16px; }
.ingredients__amount { text-align: right; white-space: nowrap; }
.ingredients__group,
.steps__group {
  padding: 24px 0 8px;
  list-style: none;
}
/* グループ名（【A】など）: 手順や材料と見分けやすいよう、等幅のチップにして先頭に # を付ける */
.group-chip {
  display: inline-block;
  padding: 2px 10px;
  font-family: var(--pc-font-mono);
  font-size: 16px;              /* 手順・材料の本文と同じ */
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: var(--pc-fg);
  background: var(--pc-code-bg);
  border: 1px solid var(--pc-border);
  border-radius: 4px;
}
.group-chip::before { content: "# "; color: var(--pc-accent); }
/* 見出しの li を手順の番号に数えない（list-item のままだと番号が 1 つずれる） */
.steps__group { display: block; }
/* ol の左の余白（番号の置き場所）を打ち消して、見出しを番号と同じ左端に揃える */
.steps__group { margin-left: -1.6em; }

.steps { margin: 0; padding-left: 1.6em; }
.steps__item { padding: 8px 0; border-bottom: 1px solid var(--pc-border); }
.steps__item::marker { font-family: var(--pc-font-mono); color: var(--pc-accent); }

.recipe__footer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.recipe__footer p { flex-basis: 100%; margin: 0; }

.notice { margin: 0 0 16px; }

/* ---------------------------------------------------------------- 入力フォーム */

.textarea { min-height: 120px; line-height: 1.7; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 13px; color: var(--pc-muted); margin-top: 4px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; min-height: var(--pc-tap); font-size: 14px; }
.form-thumb { display: block; width: 80px; height: 80px; border-radius: 8px; object-fit: cover; margin-bottom: 8px; }
.form-actions { display: flex; gap: 12px; }
.form-actions .button--primary { flex: 1; }
.alt-action { margin-top: 24px; font-size: 14px; }
.notice p { margin: 0; }

/* ---------------------------------------------------------------- 人数の切り替え */

.ingredients__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ingredients__header .label { margin: 0; }
.servings { display: flex; align-items: center; gap: 4px; }
.servings__button {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--pc-tap); height: var(--pc-tap); border: 1px solid var(--pc-border); border-radius: 999px;
  color: var(--pc-fg); text-decoration: none; font-size: 20px; line-height: 1; user-select: none;
}
.servings__button:hover, .servings__button:focus-visible { border-color: var(--pc-accent); color: var(--pc-accent); text-decoration: none; }
.servings__button--disabled { opacity: .35; }
.servings__value { min-width: 4.5em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.servings__note { font-size: 13px; color: var(--pc-muted); margin: 8px 0 4px; }
.ingredients__amount--scaled { color: var(--pc-accent); font-weight: 600; }

/* ---------------------------------------------------------------- 買い物リスト */

.button--block { display: flex; width: 100%; justify-content: center; }
.add-to-shopping { margin-top: 16px; }
.shopping { list-style: none; margin: 8px 0 0; padding: 0; }
.shopping__line { border-bottom: 1px solid var(--pc-border); }
.shopping__toggle {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 0;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.shopping__box {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border: 2px solid var(--pc-border); border-radius: 6px;
  color: #fff; font-size: 14px; font-weight: 700;
}
.shopping__line--checked .shopping__box { background: var(--pc-accent); border-color: var(--pc-accent); }
.shopping__body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.shopping__sources { font-size: 12px; color: var(--pc-muted); }
.shopping__amount { white-space: nowrap; }
.shopping__line--checked .shopping__name,
.shopping__line--checked .shopping__amount { color: var(--pc-muted); text-decoration: line-through; }
.shopping__actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }

.add-shopping__title { font-weight: 700; font-size: 1.1rem; margin: 4px 0 12px; }
.add-shopping__servings { margin-bottom: 8px; }
.pick { list-style: none; margin: 0; padding: 0; }
.pick__item {
  display: flex; align-items: center; gap: 12px; min-height: 48px;
  border-bottom: 1px solid var(--pc-border); cursor: pointer;
}
.pick__item input { width: 20px; height: 20px; accent-color: var(--pc-accent); flex: none; }
.pick__name { flex: 1; }
.pick__amount { white-space: nowrap; }
.pick__tag { font-size: 11px; color: var(--pc-muted); border: 1px solid var(--pc-border); border-radius: 4px; padding: 0 4px; }

.merge { width: 100%; border-collapse: collapse; }
.merge th { font-size: 12px; font-weight: 400; color: var(--pc-muted); text-align: left; padding: 4px 8px 4px 0; }
.merge td { border-top: 1px solid var(--pc-border); padding: 10px 8px 10px 0; }
.merge input { width: 20px; height: 20px; accent-color: var(--pc-accent); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-gap { margin-top: 32px; }

.steps__time {
  display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px;
  background: var(--pc-accent); color: #fff; font-family: var(--pc-font-mono, monospace); font-size: 12px;
  text-decoration: none; vertical-align: 1px;
}
.steps__time:hover { text-decoration: none; opacity: .85; }

/* ---------------------------------------------------------------- アクセスキー */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.new-key { margin: 16px 0; padding: 16px; border: 2px solid var(--pc-accent); border-radius: 8px; }
.new-key__warning { font-size: 14px; margin: 0 0 12px; }
.new-key__row { display: flex; gap: 8px; }
.new-key__value { flex: 1; min-width: 0; font-family: var(--pc-font-mono); font-size: 13px; }
.keys { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 14px; }
.keys th { font-size: 12px; font-weight: 400; color: var(--pc-muted); text-align: left; padding: 4px 8px 4px 0; }
.keys td { border-top: 1px solid var(--pc-border); padding: 10px 8px 10px 0; vertical-align: top; }
.keys__sub { display: block; font-size: 12px; color: var(--pc-muted); }
.keys__row--revoked td, .keys__row--expired td { color: var(--pc-muted); }
.badge { display: inline-block; font-size: 12px; padding: 0 6px; border: 1px solid var(--pc-border); border-radius: 4px; white-space: nowrap; }
.badge--active { border-color: var(--pc-accent); color: var(--pc-accent); }

/* 狭い画面では表をカードのように縦に並べる */
@media (max-width: 640px) {
  .keys thead { display: none; }
  .keys, .keys tbody, .keys tr, .keys td { display: block; width: 100%; }
  .keys tr { border-top: 1px solid var(--pc-border); padding: 10px 0; }
  .keys td { border: 0; padding: 2px 0; }
  .keys td:first-child { font-weight: 700; margin-bottom: 4px; }
  .keys td[data-label] { display: grid; grid-template-columns: 7em 1fr; gap: 8px; }
  .keys td[data-label]::before { content: attr(data-label); font-size: 12px; color: var(--pc-muted); padding-top: 2px; }
  .keys td[data-label] .keys__sub { grid-column: 2; }
  .keys td[data-label] .badge { justify-self: start; }
}
