/* ─── Tōfu Hyakuchin — style.css ─────────────────────────────── */

/* ─── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:           #F5F0E8;
  --surface:      #FFFDF7;
  --border:       #DDD5C8;
  --text:         #2C2418;
  --muted:        #7A6E5D;
  --accent:       #8B6914;
  --link:         #6B4E12;
  --link-hover:   #3D2D08;

  --radius-lg:    16px;
  --radius-md:    10px;
  --radius-sm:    6px;
  --shadow:       0 2px 8px rgba(44, 36, 24, .06), 0 0 0 1px rgba(44, 36, 24, .04);
  --shadow-hover: 0 6px 20px rgba(44, 36, 24, .1), 0 0 0 1px rgba(44, 36, 24, .06);
  --transition:   0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Grade badge colors */
  --grade-commonplace: #8B8070;
  --grade-familiar:    #6B7D5E;
  --grade-fine:        #5E7080;
  --grade-curious:     #7D5E80;
  --grade-exquisite:   #80665E;
  --grade-superb:      #8B6914;

  /* Fonts */
  --font-ja: 'Noto Serif JP', 'Hiragino Mincho Pro', serif;
  --font-en: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', 'Consolas', monospace;
}

[data-theme="dark"] {
  --bg:           #1A1610;
  --surface:      #262017;
  --border:       #3D3628;
  --text:         #E8E0D0;
  --muted:        #9A8E7D;
  --accent:       #D4A84B;
  --link:         #D4A84B;
  --link-hover:   #E8C06A;
  --shadow:       0 2px 8px rgba(0, 0, 0, .25), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-hover: 0 6px 20px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .06);

  --grade-commonplace: #9A9080;
  --grade-familiar:    #7B9D6E;
  --grade-fine:        #6E8A9A;
  --grade-curious:     #9A6E9D;
  --grade-exquisite:   #9A806E;
  --grade-superb:      #D4A84B;
}


/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-en);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}


/* ─── Links ──────────────────────────────────────────────────── */
a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--transition);
}

a:hover { color: var(--link-hover); }


/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.title-kanji {
  font-family: var(--font-ja);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.title-romaji {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.site-nav a {
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.88rem;
  color: var(--muted);
  transition: all var(--transition);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
  background: var(--bg);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  transition: all var(--transition);
  margin-left: 0.3rem;
}

.theme-toggle:hover { border-color: var(--muted); }

.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }


/* ─── Main ───────────────────────────────────────────────────── */
.site-main {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  flex: 1;
}


/* ─── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  text-align: center;
}

.footer-title {
  font-family: var(--font-ja);
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.footer-credit {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.footer-sources {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.8rem;
}

.footer-sources a { color: var(--muted); }


/* ─── Page Headings ──────────────────────────────────────────── */
.page-heading {
  margin-bottom: 2rem;
}

.page-heading h1 {
  font-family: var(--font-en);
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.page-heading .subtitle {
  color: var(--muted);
  font-style: italic;
}


/* ─── Grade Badges ───────────────────────────────────────────── */
.grade-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-ja);
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: nowrap;
}

.grade-badge small {
  font-family: var(--font-en);
  font-size: 0.75rem;
  opacity: 0.85;
}

.grade-badge--commonplace { background: color-mix(in srgb, var(--grade-commonplace) 15%, transparent); color: var(--grade-commonplace); }
.grade-badge--familiar    { background: color-mix(in srgb, var(--grade-familiar) 15%, transparent); color: var(--grade-familiar); }
.grade-badge--fine        { background: color-mix(in srgb, var(--grade-fine) 15%, transparent); color: var(--grade-fine); }
.grade-badge--curious     { background: color-mix(in srgb, var(--grade-curious) 15%, transparent); color: var(--grade-curious); }
.grade-badge--exquisite   { background: color-mix(in srgb, var(--grade-exquisite) 15%, transparent); color: var(--grade-exquisite); }
.grade-badge--superb      { background: color-mix(in srgb, var(--grade-superb) 15%, transparent); color: var(--grade-superb); }


/* ─── Grade Grid (Landing Page) ──────────────────────────────── */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.grade-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  box-shadow: var(--shadow);
}

.grade-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  color: var(--text);
}

.grade-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.grade-card-title {
  font-family: var(--font-ja);
  font-size: 1.2rem;
  font-weight: 700;
}

.grade-card-english {
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
}

.grade-card-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.grade-card-description {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.5;
}


/* ─── Recipe Card (Browse Page) ──────────────────────────────── */
.recipe-list {
  list-style: none;
}

.recipe-list-item {
  border-bottom: 1px solid var(--border);
}

.recipe-list-item:last-child { border-bottom: none; }

.recipe-list-link {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0.5rem;
  text-decoration: none;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.recipe-list-link:hover {
  background: var(--surface);
  color: var(--text);
}

.recipe-number {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 2rem;
  text-align: right;
}

.recipe-name-ja {
  font-family: var(--font-ja);
  font-size: 1rem;
}

.recipe-name-en {
  font-size: 0.88rem;
  color: var(--muted);
  margin-left: auto;
}


/* ─── Single Recipe ──────────────────────────────────────────── */
.recipe-header {
  margin-bottom: 2rem;
}

.recipe-header h1 {
  font-family: var(--font-en);
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.recipe-names {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.recipe-name-kanji {
  font-family: var(--font-ja);
  font-size: 1.4rem;
  font-weight: 700;
}

.recipe-name-romaji {
  color: var(--muted);
  font-style: italic;
}

.recipe-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.recipe-meta .recipe-id {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.recipe-english-interp {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
  margin-bottom: 1.5rem;
}

.recipe-english-interp h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.recipe-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .recipe-panels {
    grid-template-columns: 1fr 1fr;
  }
}

.recipe-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
}

.recipe-panel h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.panel-original {
  font-family: var(--font-ja);
  line-height: 1.9;
}

.panel-transliteration {
  font-style: italic;
  line-height: 1.8;
}

.panel-english {
  line-height: 1.8;
}

.panel-placeholder {
  color: var(--muted);
  font-style: italic;
  font-size: 0.88rem;
}

.recipe-notes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
  margin-bottom: 2rem;
}

.recipe-notes h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.recipe-notes p {
  line-height: 1.8;
  font-size: 0.95rem;
}


/* ─── English Recipe Section ─────────────────────────────────── */
.recipe-english-recipe {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
  margin-bottom: 2rem;
}

.recipe-english-recipe > h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.recipe-ingredients h3,
.recipe-method h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--text);
}

.recipe-method {
  margin-top: 1.5rem;
}

.panel-method {
  line-height: 1.8;
  font-size: 0.95rem;
}

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

.ingredient-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.ingredient-item:last-child {
  border-bottom: none;
}

.ingredient-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.ingredient-name {
  font-size: 0.95rem;
}

.ingredient-kanji {
  font-size: 0.82rem;
  color: var(--muted);
  margin-left: 0.4rem;
}

.ingredient-amount {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.ingredient-detail {
  display: flex;
  gap: 1rem;
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.ingredient-edo {
  font-style: italic;
}

.ingredient-note {
  font-style: italic;
}

/* ─── Recipe Navigation ──────────────────────────────────────── */
.recipe-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.recipe-nav a {
  font-size: 0.88rem;
  text-decoration: none;
  color: var(--muted);
  transition: color var(--transition);
}

.recipe-nav a:hover { color: var(--text); }

.recipe-nav .nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
}


/* ─── Glossary ───────────────────────────────────────────────── */
.glossary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.glossary-filters a {
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.glossary-filters a:hover,
.glossary-filters a.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--muted);
}

.glossary-entry {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.glossary-entry:last-child { border-bottom: none; }

.glossary-term-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.glossary-kanji {
  font-family: var(--font-ja);
  font-size: 1.15rem;
  font-weight: 700;
}

.glossary-romaji {
  font-style: italic;
  color: var(--muted);
}

.glossary-english {
  font-weight: 600;
}

.glossary-category {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
}

.glossary-definition {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
}

.glossary-backlinks {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
}

.glossary-backlinks .backlinks-label {
  font-weight: 600;
  margin-right: 0.3rem;
}

.glossary-backlinks a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--muted) 50%, transparent);
  transition: color var(--transition);
}

.glossary-backlinks a:hover {
  color: var(--text);
}


/* ─── Glossary Links (in recipe text) ────────────────────────── */
.glossary-link {
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
}


/* ─── Search ─────────────────────────────────────────────────── */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.search-input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-en);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-btn {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}

.search-btn:hover {
  background: var(--bg);
  border-color: var(--muted);
}

.search-result {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.search-result:last-child { border-bottom: none; }

.search-result h3 {
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
}

.search-result h3 a { text-decoration: none; }

.search-result p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.search-highlight {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  padding: 0.05rem 0.2rem;
  border-radius: 2px;
}


/* ─── About Page ─────────────────────────────────────────────── */
.about-content {
  max-width: 680px;
}

.about-content h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.about-content p {
  margin-bottom: 1rem;
  line-height: 1.8;
}

.about-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1.2rem 0;
  font-style: italic;
  color: var(--muted);
}

.source-list {
  list-style: decimal;
  padding-left: 1.5rem;
}

.source-list li {
  margin-bottom: 0.6rem;
  font-size: 0.92rem;
  line-height: 1.6;
}


/* ─── Browse Mode Tabs ───────────────────────────────────────── */
.browse-tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.browse-tabs a {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  text-decoration: none;
  font-size: 0.88rem;
  color: var(--muted);
  transition: all var(--transition);
}

.browse-tabs a:hover,
.browse-tabs a.active {
  color: var(--text);
  background: var(--surface);
}

.grade-section {
  margin-bottom: 2rem;
}

.grade-section-header {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.grade-section-header h2 {
  font-family: var(--font-ja);
  font-size: 1.2rem;
  font-weight: 700;
}

.grade-section-header span {
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
}

/* ─── Tag Sections (browse by technique/ingredient) ────────── */
.tag-section {
  margin-bottom: 2rem;
}

.tag-section-header {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.tag-section-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.tag-section-header h2 a {
  text-decoration: none;
  color: var(--text);
}

.tag-section-header h2 a:hover {
  color: var(--muted);
}

.tag-section-header h2 span[lang="ja"] {
  font-family: var(--font-ja);
  margin-right: 0.3rem;
}

.tag-count {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  flex-shrink: 0;
}

.recipe-list--compact .recipe-list-item {
  padding: 0.3rem 0;
}

/* ─── Recipe Tag Pills ────────────────────────────────────────── */
.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.recipe-tag {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  transition: all var(--transition);
}

.recipe-tag:hover {
  color: var(--text);
  border-color: var(--text);
}

.recipe-tag--technique {
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
}

.recipe-tag--ingredient {
  border-color: color-mix(in srgb, var(--text) 20%, transparent);
}

.recipe-tag--cultural {
  border-style: dashed;
}


/* ─── Landing Intro ──────────────────────────────────────────── */
.landing-intro {
  max-width: 680px;
  margin-bottom: 2.5rem;
}

.landing-intro p {
  margin-bottom: 1rem;
  line-height: 1.8;
}

.landing-title {
  text-align: center;
  margin-bottom: 2rem;
}

.landing-title h1 {
  font-family: var(--font-ja);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.3rem;
}

.landing-title .landing-subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  font-style: italic;
}

.landing-title .landing-subtitle-en {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 0.2rem;
}


/* ─── Utility ────────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-small { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-style: italic;
}


/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  html { font-size: 16px; }

  .header-inner {
    flex-direction: column;
    gap: 0.5rem;
  }

  .site-nav { flex-wrap: wrap; justify-content: center; }

  .landing-title h1 { font-size: 2.2rem; }

  .grade-grid {
    grid-template-columns: 1fr;
  }

  .recipe-names { flex-direction: column; gap: 0.2rem; }
  .recipe-name-en { margin-left: 0; }
}
