/* ==========================================================================
   Design tokens
   Same ledger / financial-register aesthetic as the property tracker:
   warm ruled paper, deep ink navy, a single brass accent, and stamped
   ink-green/ink-red badges — here reused for festival numbers and warnings
   instead of credits/debits.
   ========================================================================== */
:root {
    /* Surface */
    --paper: #F5F1E6;
    --paper-card: #FBF8F1;
    --rule: #DCD4BE;
    --rule-strong: #C9BE9E;

    /* Ink */
    --ink: #22262A;
    --ink-soft: #6B6558;
    --navy: #1C2E40;
    --navy-soft: #33475B;

    /* Accent */
    --brass: #A6782E;
    --brass-dark: #8A6323;
    --brass-wash: #F1E6CC;

    /* Stamp colors — credit/debit in the property tracker, repurposed here
       for "noted" (informational, turmeric-adjacent) and "caution" (DON'T /
       warning) callouts so the same visual language carries over. */
    --credit: #2C6B4A;
    --credit-wash: #E4EDE3;
    --debit: #8C3A34;
    --debit-wash: #F2E4DF;

    --radius: 4px;
    --shadow-card: 0 1px 2px rgba(28, 46, 64, 0.06), 0 1px 1px rgba(28, 46, 64, 0.04);
}

* { box-sizing: border-box; }

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

body {
    font-family: 'IBM Plex Sans', 'Noto Sans Tamil', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    color: var(--ink);
    background-color: var(--paper);
    /* Faint ruled-ledger-paper texture, same trick as the property tracker */
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(28, 46, 64, 0.035) 0px,
        rgba(28, 46, 64, 0.035) 1px,
        transparent 1px,
        transparent 29px
    );
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
    font-family: 'Roboto Slab', 'Noto Serif Tamil', Georgia, serif;
    color: var(--navy);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 12px;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 0.95rem; margin: 0 0 10px; color: var(--ink); text-transform: uppercase; letter-spacing: 0.04em; }

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--brass-dark); }

:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Top bar — same navy "ledger tab" navbar as the property tracker
   ========================================================================== */
.site-header{
    position: sticky; top: 0; z-index: 40;
    background: var(--navy);
    border-bottom: 3px solid var(--brass);
}
.header-inner{
    max-width: 1240px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
@supports (padding: max(0px)){
  .header-inner{
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    padding-top: max(14px, env(safe-area-inset-top));
  }
}
.brand{ display: flex; align-items: center; gap: 14px; }
.brand-link{
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
}
.brand-flame{ font-size: 26px; }
.brand-text h1{
    font-family: 'Roboto Slab', 'Noto Serif Tamil', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.2vw, 1.55rem);
    color: #FBF8F1;
    margin: 0;
}
.brand-sub{
    margin: 2px 0 0;
    color: rgba(251,248,241,0.65);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.nav-toggle{
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px; height: 44px;
    background: transparent;
    border: 1px solid rgba(251,248,241,0.3);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle span{
    display: block;
    height: 2px;
    margin: 0 8px;
    background: #FBF8F1;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.layout{
    max-width: 1240px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    align-items: start;
    position: relative;
    z-index: 1;
}

.sidebar{
    position: sticky;
    top: 61px;
    height: calc(100vh - 61px);
    overflow-y: auto;
    padding: 24px 18px 60px;
    border-right: 1px solid var(--rule);
    background: var(--paper-card);
}
.sidebar::-webkit-scrollbar{ width: 6px; }
.sidebar::-webkit-scrollbar-thumb{ background: var(--rule-strong); border-radius: 4px; }
@supports (padding: max(0px)){
  .sidebar{ padding-left: max(18px, env(safe-area-inset-left)); }
}

.sidebar-search{ margin-bottom: 22px; }
.sidebar-search input{
    width: 100%;
    padding: 9px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--rule-strong);
    background: #fff;
    font-family: 'IBM Plex Sans', 'Noto Sans Tamil', sans-serif;
    font-size: 16px; /* iOS won't auto-zoom on focus at this size */
    color: var(--ink);
}
.sidebar-search input:focus{
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px var(--brass-wash);
}

.nav-group{ margin-bottom: 26px; }
.nav-group-title{
    display: flex; align-items: center; gap: 8px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin: 0 0 10px 4px;
}
.title-mark{ color: var(--brass); font-family: 'Roboto Slab', 'Noto Serif Tamil', serif; }

.nav-list{ list-style: none; margin: 0; padding: 0; }
.nav-list li{ margin-bottom: 2px; }

.nav-link{
    display: flex;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    min-height: 42px;
    text-align: left;
    padding: 9px 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    font-family: 'IBM Plex Sans', 'Noto Sans Tamil', sans-serif;
    font-size: 0.9rem;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.nav-link:visited{ color: var(--ink); }
.nav-link .n{
    flex: 0 0 auto;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.72rem;
    color: var(--brass-dark);
    min-width: 18px;
}
.nav-link:hover{ background: var(--brass-wash); }
.nav-link.active,
.nav-link[aria-current="page"]{
    background: var(--paper);
    border-left-color: var(--brass);
    font-weight: 600;
}
.nav-link.active .n,
.nav-link[aria-current="page"] .n{ color: var(--brass-dark); }
.nav-link.no-detail{ opacity: 0.5; font-style: italic; }
.nav-link.hidden, .nav-list li.hidden{ display: none; }

.content{
    padding: 32px 28px 100px;
    min-width: 0;
}
@supports (padding: max(0px)){
  .content{ padding-bottom: max(100px, calc(60px + env(safe-area-inset-bottom))); }
}

article, section{ animation: rise 0.25s ease; }
@keyframes rise{
    from{ opacity: 0; transform: translateY(6px); }
    to{ opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Home / intro
   ========================================================================== */
.intro-card{
    background: var(--paper-card);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 32px 34px;
}
.intro-card h2{ margin-bottom: 10px; }
.intro-card p{ max-width: 62ch; color: var(--ink-soft); }

.intro-grid{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 26px;
}
.intro-tile{
    display: block;
    background: #fff;
    border: 1px solid var(--rule);
    border-left: 3px solid var(--brass);
    border-radius: var(--radius);
    padding: 13px 16px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.intro-tile:visited{ color: inherit; }
.intro-tile:hover{ transform: translateY(-1px); border-left-color: var(--brass-dark); }
.intro-tile .n{
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.72rem;
    color: var(--brass-dark);
}
.intro-tile .name{ font-family: 'Roboto Slab', 'Noto Serif Tamil', serif; font-size: 1rem; color: var(--navy); margin-top: 2px; }
.intro-tile--recipe .name{ font-size: 0.95rem; }
.intro-grid--recipes{ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.section-heading{
    font-family: 'Roboto Slab', 'Noto Serif Tamil', serif;
    color: var(--navy);
    margin: 36px 0 14px;
    font-size: 1.2rem;
}

.back-home-link{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 30px;
    padding: 9px 4px;
    min-height: 44px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--navy);
}
.back-home-link:hover{ color: var(--brass-dark); text-decoration: underline; }

/* ==========================================================================
   Festival pages — the festival number rendered as an ink stamp, same
   bordered/uppercase/monospace treatment as the credit/debit badges
   ========================================================================== */
.festival-head{
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 6px;
}
.festival-num{
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px; height: 58px;
    border: 2px solid var(--navy);
    border-radius: var(--radius);
    font-family: 'Noto Serif Tamil', 'Roboto Slab', serif;
    font-size: 1.5rem;
    color: var(--navy);
    background: var(--paper-card);
    transform: rotate(-2deg);
}
.festival-titles h2{ margin-bottom: 2px; }
.festival-titles .english{
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
}
.festival-note{
    margin: 16px 0 26px;
    padding: 11px 16px;
    background: var(--brass-wash);
    border-left: 4px solid var(--brass);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--ink);
}

.no-detail-note{
    margin-top: 20px;
    padding: 16px 20px;
    background: var(--paper-card);
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.section-grid{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 8px;
}
.card{
    background: var(--paper-card);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 17px 19px;
}
.card h3{ padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.card ul{ list-style: none; margin: 0; padding: 0; }
.card li{
    position: relative;
    padding: 5px 0 5px 16px;
    font-size: 0.92rem;
    color: var(--ink);
}
.card li::before{
    content: "\2014";
    position: absolute; left: 0; top: 5px;
    color: var(--brass);
    font-size: 0.75rem;
}
.card li .item-img{
    display: block;
    margin-top: 8px;
    max-width: 160px;
    border-radius: var(--radius);
    border: 1px solid var(--rule);
}

/* Warning callouts — same flash-message pattern as the property tracker:
   left-border, wash background, colored text */
.warning-box{
    margin-top: 22px;
    padding: 14px 18px;
    background: var(--debit-wash);
    color: var(--debit);
    border-left: 4px solid var(--debit);
    border-radius: var(--radius);
}
.warning-box h3{
    margin: 0 0 8px;
    font-size: 0.76rem;
    color: var(--debit);
    border: none;
    padding: 0;
}
.warning-box ul{ margin: 0; padding: 0; list-style: none; }
.warning-box li{ font-size: 0.9rem; padding: 2px 0; font-weight: 500; color: var(--debit); }
.warning-box li::before{ content: none; }

/* ==========================================================================
   Recipe pages
   ========================================================================== */
.recipe-head h2{ margin-bottom: 20px; }
.recipe-grid{
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    gap: 20px;
}
@media (max-width: 720px){
    .recipe-grid{ grid-template-columns: 1fr; }
}
.recipe-grid .card ol{ margin: 0; padding-left: 20px; }
.recipe-grid .card ol li{ padding: 6px 0; font-size: 0.92rem; }
.recipe-warning{
    margin-top: 16px;
    padding: 10px 14px;
    background: var(--brass-wash);
    border-left: 4px solid var(--brass);
    border-radius: var(--radius);
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--brass-dark);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 880px){
    .nav-toggle{ display: flex; }
    .layout{ grid-template-columns: 1fr; }
    .sidebar{
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: min(320px, 84vw);
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        padding-top: 90px;
        box-shadow: 12px 0 30px rgba(28,46,64,0.25);
    }
    .sidebar.open{ transform: translateX(0); }
    .content{ padding: 22px 18px 80px; }
    .scrim{
        display: none;
        position: fixed; inset: 0;
        background: rgba(28,46,64,0.4);
        z-index: 50;
    }
    .scrim.show{ display: block; }
}
