/* ══════════════════════════════════════════════════
   LumberLogic — The 1D Cut List Optimizer
   Design: Warm woodshop theme (dark walnut + orange)
   ══════════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
    --clr-bg: #121008;
    --clr-surface: #1c1810;
    --clr-surface-2: #26211a;
    --clr-surface-3: #302a20;
    --clr-border: #3a3228;
    --clr-border-hover: #504636;
    --clr-text: #f0e8d8;
    --clr-text-muted: #a09480;
    --clr-text-dim: #6b5f50;
    --clr-accent: #f97316;
    --clr-accent-hover: #ea580c;
    --clr-accent-glow: rgba(249, 115, 22, 0.12);
    --clr-accent-glow-strong: rgba(249, 115, 22, 0.3);
    --clr-waste: #6b7280;
    --clr-waste-bg: rgba(107, 114, 128, 0.15);
    --clr-green: #22c55e;
    --clr-green-bg: rgba(34, 197, 94, 0.12);
    --clr-yellow: #eab308;
    --clr-yellow-bg: rgba(234, 179, 8, 0.12);
    --clr-red: #ef4444;
    --clr-red-bg: rgba(239, 68, 68, 0.12);
    --clr-blue: #3b82f6;
    --clr-blue-bg: rgba(59, 130, 246, 0.12);
    --clr-kerf: #1a1612;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(249, 115, 22, 0.2);
    --font-sans: 'Outfit', 'Inter', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body); background: var(--clr-bg); color: var(--clr-text);
    line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased;
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* ═══════════════════════════════════════════
   AD SLOTS
   ═══════════════════════════════════════════ */
.ad-slot {
    display: flex; align-items: center; justify-content: center;
    border: 1px dashed var(--clr-border); color: var(--clr-text-dim);
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
    background: var(--clr-surface); border-radius: var(--radius-xs);
}
.ad-slot--mobile { height: 50px; max-width: 320px; margin: 0 auto 1rem; }
.ad-slot--desktop { display: none; height: 90px; max-width: 728px; margin: 1.5rem auto; }
@media (min-width: 768px) {
    .ad-slot--mobile { display: none; }
    .ad-slot--desktop { display: flex; }
}

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
.site-header {
    text-align: center; padding: 2.5rem 1rem 1.5rem;
    background: linear-gradient(180deg, var(--clr-surface) 0%, var(--clr-bg) 100%);
    border-bottom: 1px solid var(--clr-border);
    position: relative; overflow: hidden;
}
.site-header::before {
    content: '';
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 600px; height: 200px;
    background: radial-gradient(ellipse, rgba(249, 115, 22, 0.08) 0%, transparent 70%);
    pointer-events: none;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 0.6rem; position: relative; }
.brand-icon { font-size: 2rem; }
.brand-name {
    font-family: var(--font-sans); font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em;
}
.brand-accent { color: var(--clr-accent); }
.brand-tagline {
    font-family: var(--font-sans); font-size: 0.95rem; color: var(--clr-text-muted);
    margin-top: 0.25rem; font-weight: 500;
}
.brand-subtitle { font-size: 0.85rem; color: var(--clr-text-muted); margin-top: 0.5rem; opacity: 0.7; }

/* ═══════════════════════════════════════════
   PRIVACY BADGE
   ═══════════════════════════════════════════ */
.privacy-badge {
    display: flex; align-items: center; gap: 0.5rem; justify-content: center;
    padding: 0.6rem 1rem; margin: 1.5rem auto; max-width: 420px;
    background: var(--clr-accent-glow); border: 1px solid var(--clr-accent);
    border-radius: 100px; font-size: 0.78rem; font-weight: 500; color: var(--clr-accent);
}

/* ═══════════════════════════════════════════
   LAYOUT GRID
   ═══════════════════════════════════════════ */
.app-grid { display: grid; gap: 1.5rem; margin-top: 1.5rem; }
@media (min-width: 768px) {
    .app-grid { grid-template-columns: 380px 1fr; }
}
@media (min-width: 1024px) {
    .app-grid { grid-template-columns: 400px 1fr; }
}

/* ═══════════════════════════════════════════
   PANELS
   ═══════════════════════════════════════════ */
.panel {
    background: var(--clr-surface); border: 1px solid var(--clr-border);
    border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
}
.panel-title {
    font-family: var(--font-sans); font-size: 1.1rem; font-weight: 700;
    margin-bottom: 1.25rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--clr-border);
}

/* ═══════════════════════════════════════════
   INPUT GROUP
   ═══════════════════════════════════════════ */
.input-group { margin-bottom: 1rem; }
.input-group label {
    display: block; font-size: 0.82rem; font-weight: 600; color: var(--clr-text-muted);
    margin-bottom: 0.35rem; text-transform: uppercase; letter-spacing: 0.04em;
    font-family: var(--font-body);
}
.input-group input, .input-group select {
    width: 100%; padding: 0.7rem 0.9rem; font-size: 1rem;
    font-family: var(--font-mono); background: var(--clr-surface-2);
    border: 1px solid var(--clr-border); border-radius: var(--radius-sm);
    color: var(--clr-text); transition: border-color var(--transition);
}
.input-group input:focus {
    outline: none; border-color: var(--clr-accent);
    box-shadow: 0 0 0 3px var(--clr-accent-glow);
}
.input-group input::placeholder { color: var(--clr-text-muted); opacity: 0.5; }
.input-hint { font-size: 0.72rem; color: var(--clr-text-muted); margin-top: 0.25rem; display: block; }
.optional-tag {
    font-size: 0.68rem; font-weight: 400; color: var(--clr-text-dim);
    text-transform: none; letter-spacing: 0; font-style: italic;
}

/* ── Preset Buttons ── */
.preset-row {
    display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap;
}
.btn-preset {
    padding: 0.35rem 0.8rem; font-size: 0.78rem; font-weight: 600;
    font-family: var(--font-mono); color: var(--clr-text-muted);
    background: var(--clr-surface-2); border: 1px solid var(--clr-border);
    border-radius: var(--radius-xs); cursor: pointer;
    transition: all var(--transition); user-select: none;
}
.btn-preset:hover {
    border-color: var(--clr-accent); color: var(--clr-accent);
    background: var(--clr-accent-glow);
}
.btn-preset.active {
    background: var(--clr-accent); color: #fff;
    border-color: var(--clr-accent);
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.section-subtitle {
    font-family: var(--font-sans); font-size: 0.95rem; font-weight: 700;
    margin-top: 0.5rem; margin-bottom: 0.15rem;
}
.section-hint { font-size: 0.78rem; color: var(--clr-text-muted); margin-bottom: 0.75rem; }

/* ═══════════════════════════════════════════
   CUT LIST
   ═══════════════════════════════════════════ */
.cut-list-headers {
    display: grid; grid-template-columns: 1fr 1fr 60px 32px; gap: 0.4rem;
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--clr-text-dim); font-weight: 600; padding: 0 0 0.3rem;
    margin-bottom: 0.3rem; border-bottom: 1px solid var(--clr-border);
}
.cut-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.cut-row {
    display: grid; grid-template-columns: 1fr 1fr 60px 32px; gap: 0.4rem;
    align-items: center; animation: fadeSlideIn 0.3s ease;
}
.cut-row input {
    width: 100%; padding: 0.55rem 0.65rem; font-size: 0.88rem;
    font-family: var(--font-mono); background: var(--clr-surface-2);
    border: 1px solid var(--clr-border); border-radius: var(--radius-xs);
    color: var(--clr-text); transition: border-color var(--transition);
}
.cut-row input.cut-label {
    font-family: var(--font-body); font-size: 0.82rem;
}
.cut-row input:focus {
    outline: none; border-color: var(--clr-accent);
    box-shadow: 0 0 0 2px var(--clr-accent-glow);
}
.cut-row input::placeholder { color: var(--clr-text-muted); opacity: 0.4; font-size: 0.78rem; }
.cut-row input.input-error {
    border-color: var(--clr-red) !important;
    box-shadow: 0 0 0 2px var(--clr-red-bg) !important;
}
.cut-row .btn-remove {
    background: none; border: none; color: var(--clr-text-dim); cursor: pointer;
    font-size: 1.2rem; padding: 0.3rem; transition: color var(--transition);
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-xs);
}
.cut-row .btn-remove:hover { color: var(--clr-red); background: var(--clr-red-bg); }

.cut-list-actions { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }

.btn-add-row {
    flex: 1; padding: 0.5rem; font-size: 0.85rem; font-weight: 600;
    font-family: var(--font-sans); color: var(--clr-accent);
    background: var(--clr-accent-glow); border: 1px dashed var(--clr-accent);
    border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition);
}
.btn-add-row:hover { background: rgba(249, 115, 22, 0.2); }

.btn-clear-all {
    padding: 0.5rem 1rem; font-size: 0.82rem; font-weight: 600;
    font-family: var(--font-sans); color: var(--clr-text-dim);
    background: transparent; border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
}
.btn-clear-all:hover { color: var(--clr-red); border-color: var(--clr-red); background: var(--clr-red-bg); }

.error-message {
    padding: 0.75rem 1rem; margin-bottom: 0.75rem;
    background: var(--clr-red-bg); border: 1px solid var(--clr-red);
    border-radius: var(--radius-sm); color: var(--clr-red);
    font-size: 0.82rem; font-weight: 600;
}

.btn-calculate {
    display: block; width: 100%; padding: 0.85rem; margin-top: 0.5rem;
    font-size: 1rem; font-weight: 700; font-family: var(--font-sans);
    color: #fff; background: linear-gradient(135deg, var(--clr-accent) 0%, #ea580c 100%);
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    letter-spacing: 0.02em;
}
.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(249, 115, 22, 0.4);
}
.btn-calculate:active { transform: translateY(0); }

/* ═══════════════════════════════════════════
   SUMMARY GRID
   ═══════════════════════════════════════════ */
.summary-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem;
    margin-bottom: 1rem;
}
.summary-card {
    background: var(--clr-surface-2); border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm); padding: 0.75rem 0.5rem; text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
}
.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.summary-card--highlight {
    border-color: var(--clr-accent); background: var(--clr-accent-glow);
    box-shadow: 0 0 20px rgba(249, 115, 22, 0.15);
}
.summary-label {
    display: block; font-size: 0.65rem; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--clr-text-muted); margin-bottom: 0.25rem;
    font-weight: 600;
}
.summary-value {
    display: block; font-size: 1.15rem; font-weight: 800; font-family: var(--font-mono);
    color: var(--clr-text); line-height: 1.2;
}
.summary-card--highlight .summary-value { color: var(--clr-accent); }

/* ═══════════════════════════════════════════
   OPTIMIZATION COMPARISON
   ═══════════════════════════════════════════ */
.comparison-card {
    margin-bottom: 1rem; padding: 0.85rem 1rem;
    background: linear-gradient(135deg, var(--clr-green-bg) 0%, rgba(34, 197, 94, 0.06) 100%);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: var(--radius-sm);
}
.comparison-inner {
    display: flex; align-items: center; gap: 0.75rem;
}
.comparison-icon { font-size: 1.4rem; flex-shrink: 0; }
.comparison-text { display: flex; flex-direction: column; gap: 0.15rem; }
.comparison-title {
    font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--clr-green);
}
.comparison-detail {
    font-size: 0.82rem; font-weight: 500; color: var(--clr-text);
    font-family: var(--font-body);
}

/* ═══════════════════════════════════════════
   EXPORT BUTTONS
   ═══════════════════════════════════════════ */
.export-row { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.btn-export {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    padding: 0.6rem 0.8rem; font-size: 0.78rem; font-weight: 600;
    font-family: var(--font-sans); color: var(--clr-text-muted);
    background: var(--clr-surface-2); border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
}
.btn-export:hover {
    color: var(--clr-accent); border-color: var(--clr-accent);
    background: var(--clr-accent-glow);
}
.export-icon { font-size: 0.9rem; }

/* ═══════════════════════════════════════════
   SVG CUT DIAGRAMS
   ═══════════════════════════════════════════ */
.diagram-heading { margin-bottom: 0.75rem; }
.cut-diagrams { min-height: 100px; }
.diagram-placeholder {
    color: var(--clr-text-muted); text-align: center;
    padding: 3rem 1rem; font-size: 0.9rem;
}
.board-diagram {
    margin-bottom: 1.5rem; opacity: 0; transform: translateY(20px);
    animation: slideInBoard 0.5s ease forwards;
}
.board-diagram svg { width: 100%; height: auto; display: block; }
.board-badge {
    display: inline-flex; align-items: center; gap: 0.4rem;
    font-size: 0.82rem; font-weight: 700; color: var(--clr-text);
    margin-bottom: 0.4rem; font-family: var(--font-sans);
}
.board-badge-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; background: var(--clr-accent);
    color: #fff; border-radius: 50%; font-size: 0.72rem; font-weight: 800;
    font-family: var(--font-mono);
}
.board-badge-eff {
    font-size: 0.72rem; font-weight: 600; font-family: var(--font-mono);
    padding: 0.15rem 0.5rem; border-radius: 100px; margin-left: 0.4rem;
}
.eff-green { color: var(--clr-green); background: var(--clr-green-bg); }
.eff-yellow { color: var(--clr-yellow); background: var(--clr-yellow-bg); }
.eff-red { color: var(--clr-red); background: var(--clr-red-bg); }

/* Staggered animation delays */
.board-diagram:nth-child(1) { animation-delay: 0s; }
.board-diagram:nth-child(2) { animation-delay: 0.08s; }
.board-diagram:nth-child(3) { animation-delay: 0.16s; }
.board-diagram:nth-child(4) { animation-delay: 0.24s; }
.board-diagram:nth-child(5) { animation-delay: 0.32s; }
.board-diagram:nth-child(6) { animation-delay: 0.4s; }
.board-diagram:nth-child(7) { animation-delay: 0.48s; }
.board-diagram:nth-child(8) { animation-delay: 0.56s; }
.board-diagram:nth-child(9) { animation-delay: 0.64s; }
.board-diagram:nth-child(10) { animation-delay: 0.72s; }

@keyframes slideInBoard {
    to { opacity: 1; transform: translateY(0); }
}

/* SVG hover glow effect */
.board-diagram svg rect.cut-segment { cursor: pointer; }
.board-diagram svg rect.cut-segment:hover { filter: brightness(1.25); }

/* ═══════════════════════════════════════════
   SVG TOOLTIP
   ═══════════════════════════════════════════ */
.svg-tooltip {
    position: fixed; z-index: 1000;
    background: #2a2318; color: var(--clr-text);
    padding: 0.55rem 0.85rem; border-radius: var(--radius-sm);
    font-family: var(--font-mono); font-size: 0.78rem; font-weight: 500;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--clr-border);
    pointer-events: none; white-space: nowrap;
    max-width: 280px; line-height: 1.5;
}
.svg-tooltip .tt-label { color: var(--clr-accent); font-weight: 700; }
.svg-tooltip .tt-dim { color: var(--clr-text-muted); }

/* ═══════════════════════════════════════════
   WASTE BREAKDOWN TABLE
   ═══════════════════════════════════════════ */
.waste-breakdown { margin-top: 1.5rem; }
.waste-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.waste-table {
    width: 100%; border-collapse: collapse; font-size: 0.78rem;
    font-family: var(--font-mono);
}
.waste-table thead { border-bottom: 2px solid var(--clr-border); }
.waste-table th {
    padding: 0.5rem 0.6rem; text-align: left; font-size: 0.68rem;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--clr-text-muted); font-weight: 600; white-space: nowrap;
}
.waste-table td {
    padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--clr-border);
    color: var(--clr-text); vertical-align: middle;
}
.waste-table td:first-child { font-weight: 700; }
.waste-table td.cuts-cell {
    font-family: var(--font-body); font-size: 0.72rem;
    color: var(--clr-text-muted); max-width: 200px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.eff-badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 100px;
    font-weight: 700; font-size: 0.72rem;
}

/* ═══════════════════════════════════════════
   HOW IT WORKS
   ═══════════════════════════════════════════ */
.how-it-works {
    margin-top: 2rem; padding: 0;
}
.how-title { text-align: center; border-bottom: none; padding-bottom: 0; margin-bottom: 1.5rem; }
.how-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;
}
@media (min-width: 768px) {
    .how-grid { grid-template-columns: repeat(4, 1fr); }
}
.how-card {
    background: var(--clr-surface); border: 1px solid var(--clr-border);
    border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center;
    transition: transform var(--transition), box-shadow var(--transition);
}
.how-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    border-color: var(--clr-border-hover);
}
.how-icon { font-size: 1.8rem; display: block; margin-bottom: 0.6rem; }
.how-card-title {
    font-family: var(--font-sans); font-size: 0.9rem; font-weight: 700;
    margin-bottom: 0.4rem; color: var(--clr-text);
}
.how-card p { font-size: 0.78rem; color: var(--clr-text-muted); line-height: 1.5; }

/* ═══════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════ */
.toast {
    position: fixed; bottom: -60px; left: 50%; transform: translateX(-50%);
    background: var(--clr-surface-3); color: var(--clr-text);
    padding: 0.75rem 1.5rem; border-radius: 100px;
    font-size: 0.85rem; font-weight: 600; font-family: var(--font-sans);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); border: 1px solid var(--clr-border);
    z-index: 2000; transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
}
.toast.show { bottom: 2rem; }

/* ═══════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════ */
.site-footer {
    text-align: center; padding: 2rem 1rem; margin-top: 2.5rem;
    border-top: 1px solid var(--clr-border); font-size: 0.8rem; color: var(--clr-text-muted);
}
.footer-privacy { margin-bottom: 0.5rem; font-weight: 500; }
.footer-disclaimer { margin-bottom: 0.5rem; font-size: 0.72rem; opacity: 0.7; font-style: italic; }
.footer-copyright { font-size: 0.75rem; }

/* ═══════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════ */
.hidden { display: none !important; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE POLISH
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
    .brand-name { font-size: 1.4rem; }
    .brand-icon { font-size: 1.6rem; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .summary-value { font-size: 1rem; }
    .summary-label { font-size: 0.6rem; }
    .cut-list-headers { grid-template-columns: 0.8fr 1fr 50px 28px; gap: 0.3rem; }
    .cut-row { grid-template-columns: 0.8fr 1fr 50px 28px; gap: 0.3rem; }
    .cut-row input { padding: 0.5rem; font-size: 0.82rem; }
    .how-grid { grid-template-columns: 1fr; }
    .export-row { flex-direction: column; }
    .waste-table { font-size: 0.7rem; }
    .waste-table th, .waste-table td { padding: 0.4rem; }
}

@media (min-width: 768px) {
    .brand-name { font-size: 2rem; }
    .brand-icon { font-size: 2.4rem; }
    .panel { padding: 1.75rem; }
    .summary-value { font-size: 1.3rem; }
}

/* ═══════════════ AFFILIATE & SEO ═══════════════ */
.seo-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 2rem 0;
}
.seo-card h2 {
    color: var(--clr-text);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}
.seo-card p {
    color: var(--clr-text-muted);
    line-height: 1.6;
}
.affiliate-gear a {
    color: var(--clr-accent);
    font-weight: 600;
    text-decoration: none;
}
.affiliate-gear a:hover {
    color: var(--clr-text);
    text-decoration: underline;
}
/* ── Scrollbar Styling ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--clr-bg); }
::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--clr-border-hover); }
