/* ============================================================
   Food & Mood Tracker — "Recipe Box" design system
   ============================================================ */

:root {
    /* Color */
    --plum-900: #2E1A2E;
    --plum-700: #4A3049;
    --ink-700: #4A3A47;
    --cream-50: #FBF7F1;
    --paper: #FFFDF9;
    --border-soft: #E8DDD1;

    --marigold-500: #E2A33D;
    --marigold-600: #C98A28;
    --marigold-100: #F7E4C3;

    --basil-600: #5C7F52;
    --basil-100: #E4EEDF;

    --berry-500: #C15B6F;
    --berry-100: #F6DEE3;

    --error-600: #A0342A;
    --error-100: #FBE4E1;

    /* Type */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --radius: 12px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink-700);
    background: var(--cream-50);
}

/* Faint dot-grid, like graph-paper in a kept journal */
.page-texture {
    min-height: 100vh;
    background-image: radial-gradient(var(--border-soft) 1px, transparent 1px);
    background-size: 22px 22px;
}

a { color: inherit; }

/* ---------------- Header ---------------- */

.app-header {
    background: var(--plum-900);
    padding: 30px 24px 0;
}

.app-header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 22px;
}

.app-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.btn-header-link {
    background: transparent;
    color: var(--cream-50);
    border: 1.5px solid rgba(251, 247, 241, 0.35);
    padding: 8px 16px;
    font-size: 0.82rem;
    white-space: nowrap;
    margin-top: 4px;
}

.btn-header-link:hover {
    background: rgba(251, 247, 241, 0.1);
    border-color: var(--marigold-500);
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--marigold-500);
    margin: 0 0 6px;
}

.app-header h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 2.4rem;
    color: var(--cream-50);
    margin: 0;
    letter-spacing: -0.01em;
}

.app-header h1 .amp {
    font-style: italic;
    font-weight: 500;
    color: var(--marigold-500);
    padding: 0 2px;
}

/* Tabs styled like folder tabs poking up from the page below */
.tabs {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    gap: 6px;
    padding: 0 24px;
}

.tabs a {
    display: flex;
    align-items: baseline;
    gap: 6px;
    text-decoration: none;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.92rem;
    color: rgba(251, 247, 241, 0.6);
    background: rgba(251, 247, 241, 0.06);
    padding: 10px 18px;
    border-radius: 10px 10px 0 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.tabs a .tab-index {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    opacity: 0.75;
}

.tabs a:hover {
    background: rgba(251, 247, 241, 0.12);
    color: var(--cream-50);
}

.tabs a.active {
    background: var(--cream-50);
    color: var(--plum-900);
}

.tabs a.active .tab-index {
    color: var(--marigold-600);
    opacity: 1;
}

/* ---------------- Layout ---------------- */

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ---------------- Flash messages ---------------- */

.flash-messages { margin-bottom: 20px; }

.flash {
    padding: 11px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.flash-success { background: var(--basil-100); color: var(--basil-600); border-color: #cfe0c7; }
.flash-error { background: var(--error-100); color: var(--error-600); border-color: #f0c7c2; }

/* ---------------- Entry form: the "recipe card" signature ---------------- */

.card-stack {
    position: relative;
    max-width: 560px;
}

/* A second card peeking out behind, tilted — the stacked index-card motif */
.card-stack::before {
    content: '';
    position: absolute;
    inset: 14px -10px -14px 10px;
    background: var(--marigold-100);
    border-radius: var(--radius);
    transform: rotate(-2deg);
    z-index: 0;
}

.entry-form {
    position: relative;
    z-index: 1;
    background: var(--paper);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    box-shadow: 0 10px 30px -14px rgba(46, 26, 46, 0.25);
}

.form-section { padding: 4px 0; }

.section-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--marigold-600);
    margin: 0 0 14px;
}

.section-divider {
    border-top: 2px dashed var(--border-soft);
    margin: 20px 0;
}

.field-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.field-row .field { flex: 1 1 140px; }

.field { margin-bottom: 16px; display: flex; flex-direction: column; }

.field label {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.86rem;
    color: var(--plum-700);
}

.required { color: var(--error-600); }

.field input[type="date"],
.field input[type="text"],
.field select,
.field textarea {
    padding: 9px 11px;
    border: 1.5px solid var(--border-soft);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: var(--font-body);
    background: var(--cream-50);
    color: var(--ink-700);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--marigold-500);
    box-shadow: 0 0 0 3px var(--marigold-100);
}

.field textarea { resize: vertical; font-family: var(--font-body); }

.required-note {
    font-size: 0.8rem;
    color: var(--ink-700);
    opacity: 0.65;
    font-style: italic;
    margin: 6px 0 18px;
}

.actions { display: flex; gap: 10px; }

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary {
    background: var(--marigold-500);
    color: var(--plum-900);
    box-shadow: 0 3px 0 var(--marigold-600);
}
.btn-primary:hover { background: #eaad48; }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--marigold-600); }

.btn-secondary {
    background: transparent;
    color: var(--plum-700);
    border: 1.5px solid var(--border-soft);
}
.btn-secondary:hover { background: var(--marigold-100); border-color: var(--marigold-500); }

.btn-danger { background: var(--error-100); color: var(--error-600); }
.btn-danger:hover { background: #f6d2cd; }

.btn-small { padding: 5px 12px; font-size: 0.78rem; }

.row-actions { display: flex; gap: 6px; }

/* ---------------- History table ---------------- */

.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1 1 160px;
    background: var(--paper);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: 0 8px 22px -16px rgba(46, 26, 46, 0.25);
}

.stat-card .section-eyebrow { margin: 0 0 8px; }

.stat-card.single-stat { flex: 0 1 200px; }

.stat-value {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 600;
    color: var(--plum-900);
}

.history-actions { margin-bottom: 18px; }

.table-wrap {
    overflow-x: auto;
    background: var(--paper);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px -18px rgba(46, 26, 46, 0.2);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
}

.history-table th, .history-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

.history-table td.description-cell { white-space: normal; min-width: 180px; color: var(--ink-700); }

.history-table th {
    background: var(--cream-50);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--plum-700);
    font-weight: 600;
}

.history-table tbody tr:hover { background: #FDF9F2; }

.mono { font-family: var(--font-mono); font-size: 0.83rem; color: var(--plum-700); }

.empty-row { text-align: center; color: var(--ink-700); opacity: 0.6; padding: 32px; font-style: italic; }

/* "Spice jar label" pills for genre / mood / health values */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.pill-genre { background: var(--marigold-100); color: var(--marigold-600); }
.pill-mood { background: var(--berry-100); color: var(--berry-500); }
.pill-health { background: var(--basil-100); color: var(--basil-600); }

/* ---------------- Graphs ---------------- */

.graph-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.graph-controls label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--plum-700);
}

.graph-controls select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid var(--border-soft);
    background: var(--paper);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--ink-700);
}

.chart-wrap {
    background: var(--paper);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 10px 30px -18px rgba(46, 26, 46, 0.2);
}

.chart-wrap + .chart-wrap { margin-top: 20px; }

.chart-slot svg,
.donut-wrap svg {
    width: 100%;
    height: auto;
    display: block;
}

.weight-stat-card {
    margin-top: 20px;
    max-width: 260px;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 640px) {
    .app-header h1 { font-size: 1.9rem; }
    .app-header-top { flex-direction: column; align-items: flex-start; }
    .btn-header-link { margin-top: 0; }
    .tabs { overflow-x: auto; }
    .tabs a { padding: 9px 13px; font-size: 0.85rem; white-space: nowrap; }
    .card-stack { max-width: 100%; }
    .entry-form { padding: 20px; }
    .container { padding: 24px 16px 48px; }
}

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