/* ============================================================
   lunchbox.dev — a developer toolkit, neatly packed
   Palette:
     #fafaf8  Rice Paper          (primary background)
     #1a1a1a  Bento Lacquer       (primary text, borders)
     #e8e4dc  Bamboo Divider      (compartment borders, separators)
     #c75c2a  Umeboshi Red        (primary accent)
     #4a7c59  Shiso Green         (secondary accent, success)
     #f5f0e8  Inner Compartment   (block backgrounds)
     #8b7d6b  Wooden Chopstick    (muted text, metadata)
   Type (all Google Fonts):
     Display : "Space Grotesk" (Google Fonts) 500
     Body    : "Inter" (Google Fonts) 400 / 0.95rem / 1.7
     Mono    : "JetBrains Mono" (Google Fonts) 400 / 0.85rem
   ============================================================ */

/* -------- reset & root -------- */
*, *::before, *::after { box-sizing: border-box; }

:root {
    --rice:        #fafaf8;
    --lacquer:     #1a1a1a;
    --bamboo:      #e8e4dc;
    --umeboshi:    #c75c2a;
    --shiso:       #4a7c59;
    --inner:       #f5f0e8;
    --chopstick:   #8b7d6b;

    --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-body:    "Inter", system-ui, -apple-system, sans-serif;
    --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

    --gutter:       8px;
    --pad-cell:     clamp(1rem, 2vw, 1.5rem);
    --max-w:        960px;

    --r-cell:       2px;
    --r-chip:       2px;

    --border-soft:  1px solid var(--bamboo);
    --border-firm:  1px solid var(--lacquer);

    --tx-fast:      120ms ease-out;
    --tx-mid:       200ms ease-out;
    --tx-slow:      400ms ease-out;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--rice);
    color: var(--lacquer);
}

body {
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.7;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(26, 26, 26, 0.035) 1px, transparent 0);
    background-size: 22px 22px;
    background-attachment: fixed;
}

/* paper grain -- a soft, almost imperceptible texture */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(250,250,248,0) 0%, rgba(250,250,248,0.6) 100%);
    z-index: 0;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--lacquer);
    letter-spacing: -0.01em;
    margin: 0;
}

p { margin: 0; }

a { color: var(--lacquer); text-decoration: none; }

code, pre, .mono { font-family: var(--font-mono); }

/* -------- page wrapper -------- */
.page {
    position: relative;
    z-index: 1;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem) clamp(2rem, 5vw, 4rem);
}

/* ============================================================
   LID  /  HERO
   ============================================================ */
.lid {
    position: relative;
    margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
    padding: clamp(1.75rem, 4vw, 3rem) clamp(1.5rem, 4vw, 2.5rem);
    background: var(--rice);
    border: var(--border-firm);
    border-radius: var(--r-cell);
    transform: perspective(900px) rotateX(-15deg);
    transform-origin: top center;
    opacity: 0;
    box-shadow:
        0 1px 0 0 rgba(26, 26, 26, 0.04),
        0 14px 40px -22px rgba(26, 26, 26, 0.18);
}

.lid.is-open {
    animation: lid-open 800ms ease-out forwards;
}

@keyframes lid-open {
    0%   { transform: perspective(900px) rotateX(-15deg); opacity: 0; }
    40%  { opacity: 1; }
    100% { transform: perspective(900px) rotateX(0deg);   opacity: 1; }
}

.lid-inner {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.lid-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--chopstick);
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

.meta-dot { color: var(--bamboo); }

.lid-title {
    font-size: clamp(1.5rem, 3vw, 2.8rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.lid-tagline {
    color: var(--lacquer);
    max-width: 52ch;
    font-size: 1.025rem;
}

.lid-stamps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin-top: 0.25rem;
}

.stamp {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.32rem 0.6rem;
    border: var(--border-soft);
    border-radius: var(--r-chip);
    background: var(--inner);
    font-size: 0.78rem;
    color: var(--lacquer);
}

.stamp-mono {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--chopstick);
    background: transparent;
}

.stamp-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--shiso);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.18);
}

/* lid hinge -- four small pins along the top edge */
.lid-hinge {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 18px;
    padding: 4px 10px;
    background: var(--rice);
}

.hinge-pin {
    display: inline-block;
    width: 8px;
    height: 4px;
    background: var(--bamboo);
    border-radius: 1px;
}

/* ============================================================
   TIER  (shared)
   ============================================================ */
.tier {
    margin: clamp(1.25rem, 2.5vw, 2rem) 0;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.tier.is-revealed {
    opacity: 1;
    transform: translateY(0);
}

.tier-header {
    display: flex;
    align-items: baseline;
    gap: 0.85rem;
    margin: 0 4px 0.85rem;
    padding-bottom: 0.65rem;
    border-bottom: var(--border-soft);
}

.tier-num {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--umeboshi);
    letter-spacing: 0.04em;
    padding: 0.18rem 0.42rem;
    border: 1px solid var(--umeboshi);
    border-radius: var(--r-chip);
    background: rgba(199, 92, 42, 0.06);
}

.tier-heading {
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    font-weight: 500;
}

.tier-sub {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--chopstick);
}

/* ============================================================
   GRID  /  COMPARTMENTS
   ============================================================ */
.grid { display: grid; gap: var(--gutter); }

.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: 2fr 1fr; }
.grid-1 { grid-template-columns: 1fr; }

@media (max-width: 760px) {
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}

.cell {
    position: relative;
    padding: var(--pad-cell);
    background: var(--inner);
    border: 1px solid var(--bamboo);
    border-radius: var(--r-cell);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    transition: border-color var(--tx-mid), background-color var(--tx-mid), transform var(--tx-mid);
    overflow: hidden;
}

.cell::after {
    /* a thin inner shadow line, like the inside seam of a compartment */
    content: "";
    position: absolute;
    inset: 4px;
    border: 1px dashed transparent;
    border-radius: 1px;
    pointer-events: none;
    transition: border-color var(--tx-mid);
}

.cell:hover {
    border-color: var(--umeboshi);
    background: var(--rice);
    transform: translateY(-1px);
}

.cell:hover::after {
    border-color: rgba(199, 92, 42, 0.18);
}

.cell-tag {
    position: absolute;
    top: 0.6rem;
    left: 0.7rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--chopstick);
    letter-spacing: 0.05em;
}

.cell-title {
    margin-top: 0.7rem;
    font-size: 1.18rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.cell-body {
    color: #2a2a2a;
    font-size: 0.95rem;
    line-height: 1.65;
}

.cell-body em {
    font-style: italic;
    color: var(--umeboshi);
}

.cell-body code {
    font-size: 0.82rem;
    padding: 0.05rem 0.35rem;
    background: var(--bamboo);
    border-radius: 1px;
}

.cell-snippet {
    margin-top: auto;
    background: var(--rice);
    border: 1px solid var(--bamboo);
    border-radius: var(--r-cell);
    padding: 0.7rem 0.85rem;
    overflow-x: auto;
}

.cell-snippet pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--lacquer);
    white-space: pre;
}

.cell-snippet code {
    font-family: inherit;
    color: inherit;
    background: transparent;
    padding: 0;
}

.cell-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.35rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--bamboo);
    border-radius: var(--r-chip);
    background: var(--rice);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--chopstick);
    letter-spacing: 0.02em;
}

.chip-green {
    color: var(--shiso);
    border-color: rgba(74, 124, 89, 0.45);
    background: rgba(74, 124, 89, 0.06);
}

.chip-orange {
    color: var(--umeboshi);
    border-color: rgba(199, 92, 42, 0.45);
    background: rgba(199, 92, 42, 0.06);
}

/* ============================================================
   STRAP DIVIDER  (lunchbox elastic band)
   ============================================================ */
.strap {
    position: relative;
    height: 32px;
    margin: clamp(1.25rem, 2.5vw, 2rem) 0;
    background: linear-gradient(
        90deg,
        var(--umeboshi) 0%,
        var(--umeboshi) 40%,
        transparent 40%,
        transparent 60%,
        var(--umeboshi) 60%,
        var(--umeboshi) 100%
    );
    border-radius: 1px;
    box-shadow: 0 1px 0 0 rgba(26, 26, 26, 0.06) inset;
    overflow: hidden;
}

/* subtle weave pattern on the elastic */
.strap::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            rgba(0, 0, 0, 0.06) 0 2px,
            transparent 2px 6px
        );
    mix-blend-mode: multiply;
    pointer-events: none;
}

.strap-tag {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--chopstick);
    background: var(--rice);
    padding: 0.18rem 0.55rem;
    border: var(--border-soft);
    border-radius: var(--r-chip);
    letter-spacing: 0.04em;
    z-index: 2;
}

/* ============================================================
   TIER 2 — note list / sheet list
   ============================================================ */
.note-list {
    list-style: none;
    margin: 0.25rem 0 0;
    padding: 0;
    border-top: 1px solid var(--bamboo);
}

.note {
    display: grid;
    grid-template-columns: minmax(96px, auto) 1fr auto;
    gap: 0.85rem;
    align-items: baseline;
    padding: 0.7rem 0.1rem;
    border-bottom: 1px solid var(--bamboo);
    transition: background var(--tx-mid), padding var(--tx-mid);
    cursor: pointer;
}

.note:hover {
    background: var(--rice);
    padding-left: 0.45rem;
}

.note-date {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--chopstick);
    letter-spacing: 0.02em;
}

.note-title {
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 500;
    color: var(--lacquer);
}

.note:hover .note-title { color: var(--umeboshi); }

.note-len {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--chopstick);
}

.sheet-list {
    list-style: none;
    margin: 0.25rem 0 0;
    padding: 0;
}

.sheet-list li {
    display: flex;
    align-items: baseline;
    gap: 0.7rem;
    padding: 0.55rem 0.1rem;
    border-bottom: 1px dashed var(--bamboo);
    transition: color var(--tx-mid), padding var(--tx-mid);
    cursor: pointer;
}

.sheet-list li:last-child { border-bottom: none; }

.sheet-list li:hover {
    color: var(--umeboshi);
    padding-left: 0.4rem;
}

.sheet-mono {
    flex: 0 0 auto;
    width: 2.6rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--umeboshi);
    letter-spacing: 0.04em;
}

.sheet-name {
    font-size: 0.92rem;
    color: var(--lacquer);
}

.sheet-list li:hover .sheet-name { color: var(--umeboshi); }

/* ============================================================
   TIER 3 — community / wide
   ============================================================ */
.cell-full { padding: clamp(1.25rem, 3vw, 2rem); }

.community {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: clamp(1rem, 3vw, 2rem);
    align-items: stretch;
    padding-top: 0.4rem;
}

@media (max-width: 760px) {
    .community { grid-template-columns: 1fr; }
}

.community-lead { display: flex; flex-direction: column; gap: 0.85rem; }

.community-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.35rem;
}

.action {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--lacquer);
    border-radius: var(--r-cell);
    background: var(--rice);
    transition: background var(--tx-mid), color var(--tx-mid), border-color var(--tx-mid), transform var(--tx-mid);
}

.action-label {
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 500;
}

.action-mono {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--chopstick);
    letter-spacing: 0.04em;
}

.action:hover {
    background: var(--lacquer);
    color: var(--rice);
    border-color: var(--lacquer);
    transform: translateY(-1px);
}

.action:hover .action-mono { color: rgba(250, 250, 248, 0.7); }

.action-primary {
    background: var(--umeboshi);
    border-color: var(--umeboshi);
    color: var(--rice);
}

.action-primary .action-mono { color: rgba(250, 250, 248, 0.75); }

.action-primary:hover {
    background: var(--lacquer);
    border-color: var(--lacquer);
}

.community-stats {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 1rem;
    background: var(--rice);
    border: 1px solid var(--bamboo);
    border-radius: var(--r-cell);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px dashed var(--bamboo);
}

.stat:last-child { border-bottom: none; }

.stat-num {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 500;
    color: var(--lacquer);
    letter-spacing: -0.01em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--chopstick);
    letter-spacing: 0.03em;
}

/* ============================================================
   COLOPHON
   ============================================================ */
.colophon {
    margin-top: clamp(2rem, 4vw, 3rem);
    padding-top: 1.25rem;
    border-top: var(--border-soft);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    color: var(--chopstick);
}

.colophon-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
}

.colophon-mono {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.colophon-text {
    font-size: 0.84rem;
    color: var(--lacquer);
}

.colophon-text .leaf {
    color: var(--shiso);
    font-style: italic;
}

.colophon-bottom { color: var(--chopstick); }

.colophon-lid {
    cursor: pointer;
    color: var(--umeboshi);
    transition: color var(--tx-fast), letter-spacing var(--tx-fast);
}

.colophon-lid:hover {
    color: var(--lacquer);
    letter-spacing: 0.06em;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .lid { animation: none !important; transform: none; opacity: 1; }
    .tier { transition: none; opacity: 1; transform: none; }
    .cell, .note, .sheet-list li, .action { transition: none; }
}
