/* ==========================================================================
   The Minding Box — main stylesheet
   ========================================================================== */

:root {
    --color-primary: #5B7A57;
    --color-primary-dark: #46603F;
    --color-accent: #D97B5C;
    --color-accent-dark: #BD5F42;
    --color-bg: #FBF3E1;
    --color-surface: #ffffff;
    --color-text: #4A3730;
    --color-text-light: #8A7568;
    --color-border: #E9DCC3;
    --color-success-bg: #e3f6ee;
    --color-success-text: #1f7a55;
    --color-error-bg: #fdecec;
    --color-error-text: #b3261e;
    --color-info-bg: #eaf3fb;
    --color-info-text: #1d5f8f;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 16px rgba(74, 55, 48, 0.08);
    --shadow-hover: 0 8px 24px rgba(74, 55, 48, 0.14);
    --font-heading: 'Bree Serif', 'Georgia', serif;
    --font-body: 'Nunito', 'Segoe UI', sans-serif;
    --max-width: 1200px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.6;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--color-text);
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }

a {
    color: var(--color-primary-dark);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ---- Buttons -------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 0.65em 1.4em;
    border-radius: 999px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--color-text); border: 2px solid var(--color-border); }
.btn-secondary:hover { border-color: var(--color-primary); color: var(--color-text); }
.btn-large { padding: 0.9em 2em; font-size: 1.1rem; }
.btn-favorite { background: #fff; border: 2px solid var(--color-accent); color: var(--color-accent-dark); }
.btn-link { background: none; border: none; color: var(--color-primary-dark); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.btn-link-danger { color: var(--color-error-text); }

/* ---- Alerts ---------------------------------------------------------- */
.alert {
    padding: 0.85em 1.2em;
    border-radius: var(--radius-sm);
    margin-bottom: 1em;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }
.alert-error { background: var(--color-error-bg); color: var(--color-error-text); }
.alert-info { background: var(--color-info-bg); color: var(--color-info-text); }
.alert-page { max-width: var(--max-width); margin: 1em auto 0; }

/* ---- Header / nav ----------------------------------------------------- */
.site-header {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.site-header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.9em 1.5em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75em;
}
.site-logo {
    display: flex;
    align-items: center;
}
.site-logo-img {
    height: 52px;
    width: auto;
    display: block;
}
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5em;
}
.nav-toggle span { width: 24px; height: 2px; background: var(--color-text); }

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.4em;
    flex-wrap: wrap;
}
.site-nav > a { font-weight: 600; color: var(--color-text); }
.site-nav > a:hover { color: var(--color-primary-dark); }
.nav-account {
    background: var(--color-primary);
    color: #fff !important;
    padding: 0.45em 1.1em;
    border-radius: 999px;
}
.nav-account:hover { background: var(--color-primary-dark); }

.nav-search {
    display: flex;
    align-items: center;
}
.nav-search input {
    border: 1px solid var(--color-border);
    border-radius: 999px 0 0 999px;
    padding: 0.45em 1em;
    font-family: var(--font-body);
}
.nav-search button {
    border: 1px solid var(--color-border);
    border-left: none;
    background: var(--color-bg);
    border-radius: 0 999px 999px 0;
    padding: 0.45em 0.8em;
    cursor: pointer;
}

/* ---- Layout ------------------------------------------------------------ */
.site-body {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5em 3em;
}
.page-heading { padding-top: 1.5em; }
.page-heading--with-icon { display: flex; align-items: center; gap: 1em; }
.page-heading-icon { width: 64px; height: 64px; object-fit: contain; border-radius: 50%; background: var(--color-surface); box-shadow: var(--shadow); flex-shrink: 0; }
.page-heading-desc { color: var(--color-text-light); }
.breadcrumb { color: var(--color-text-light); font-size: 0.9rem; }
.narrow-content { max-width: 700px; }
.legal-content h2 { margin-top: 1.4em; font-size: 1.2rem; }
.legal-content ul { padding-left: 1.4em; }
.legal-content li { margin-bottom: 0.4em; }

.page-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2em;
}
.page-main { min-width: 0; }

/* ---- Hero --------------------------------------------------------------- */
.hero {
    position: relative;
    background-image: url('/assets/img/brand/hero-illustration.jpg');
    background-size: cover;
    background-position: center 65%;
    border-radius: var(--radius);
    margin-top: 1.5em;
    min-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2em;
    text-align: center;
}
.hero-inner {
    max-width: 620px;
    margin: 0 auto;
    background: rgba(251, 243, 225, 0.9);
    border-radius: var(--radius);
    padding: 1.8em 2.2em;
}
.hero h1 { color: var(--color-text); font-size: 2.1rem; }
.hero p { color: var(--color-text); font-size: 1.05rem; }
.hero .btn-primary { background: var(--color-accent); color: #fff; }
.hero .btn-primary:hover { background: var(--color-accent-dark); color: #fff; }

/* ---- Category tiles ------------------------------------------------------ */
.category-tiles-section { margin: 2.5em 0; }
.category-search-wrap { margin: 1.5em 0; }
.category-search-input {
    width: 100%;
    max-width: 420px;
    padding: 0.7em 1.1em;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 1rem;
    display: block;
}
.category-search-empty { color: var(--color-text-light); margin-top: 1em; }
.category-tiles-viewall { text-align: center; margin-top: 1.5em; }
.category-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1em;
}
.category-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.4em 1em;
    text-align: center;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--color-text);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6em;
}
.category-tile[hidden] { display: none; }
.category-tile-icon {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 50%;
    background: var(--color-bg);
}
.category-tile:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--color-primary);
    text-decoration: none;
    color: var(--color-primary-dark);
}
/* ---- Activity grid / cards ------------------------------------------------ */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1.5em;
    margin: 1.5em 0;
}
.activity-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    color: var(--color-text);
    display: flex;
    flex-direction: column;
}
.activity-card:hover { box-shadow: var(--shadow-hover); text-decoration: none; }
.activity-card--subcategory { border: 2px solid var(--color-accent); }
.activity-card--subcategory .activity-card-badge { background: var(--color-accent); }
.activity-card-thumb {
    aspect-ratio: 4 / 3;
    background: var(--color-bg);
    overflow: hidden;
}
.activity-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.activity-card-thumb-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #fdf1e3, #f6e4c9);
}
.activity-card-body { padding: 1em 1.1em; flex: 1; display: flex; flex-direction: column; }
.activity-card-badge {
    display: inline-block;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.2em 0.7em;
    border-radius: 999px;
    margin-bottom: 0.6em;
    align-self: flex-start;
}
.activity-card-title { font-size: 1.05rem; margin-bottom: 0.4em; }
.activity-card-desc { font-size: 0.9rem; color: var(--color-text-light); margin: 0; }

/* ---- Activity detail page -------------------------------------------------- */
.activity-detail { display: grid; grid-template-columns: 1fr; gap: 2em; }
.activity-detail-meta { color: var(--color-text-light); font-size: 0.9rem; }
.activity-detail-actions { display: flex; gap: 0.8em; flex-wrap: wrap; margin: 1.5em 0 2em; }

.subcategory-header-image {
    margin: 0 0 2em;
    text-align: center;
}
.subcategory-header-image img {
    max-width: 100%;
    width: 700px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.activity-example-image {
    margin: 0 0 2em;
}
.activity-example-image-label {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-light);
    margin: 0 0 0.5em;
}
.activity-example-image img {
    max-width: 320px;
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    display: block;
}

.activity-description-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5em 1.7em;
    margin: 0 0 2em;
}
.activity-description-box h2 {
    font-family: var(--font-heading);
    font-size: 1rem;
    letter-spacing: 0.02em;
    color: var(--color-primary-dark);
    margin: 0 0 0.7em;
}
.activity-description-box p {
    font-family: var(--font-body);
    font-size: 1.03rem;
    line-height: 1.75;
    color: var(--color-text);
    margin: 0 0 0.9em;
}
.activity-description-box p:last-child { margin-bottom: 0; }

.annotate-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5em;
    margin-top: 1em;
}
.annotate-workspace { margin-top: 1.5em; }
.annotate-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6em;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 0.8em;
    margin-bottom: 1em;
}
.annotate-tool {
    background: #fff;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5em 0.9em;
    cursor: pointer;
    font-family: var(--font-body);
}
.annotate-tool.active { border-color: var(--color-primary); background: #eafaf7; }
.annotate-width-label { font-size: 0.85rem; display: flex; align-items: center; gap: 0.4em; }
.annotate-pager { display: flex; align-items: center; gap: 1em; margin-bottom: 1em; }
.annotate-canvas-stack {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: #f4f4f4;
    min-height: 300px;
    display: flex;
    justify-content: center;
    padding: 1em;
    overflow: auto;
    touch-action: pan-x pan-y;
}
.annotate-page-wrap { position: relative; margin: 0 auto; }
.annotate-page-wrap canvas { position: absolute; top: 0; left: 0; }
.annotate-page-wrap .pdf-canvas { box-shadow: var(--shadow); background: #fff; }
/* The drawing layer must swallow touch gestures itself (no native scroll/zoom while a
   finger is on the canvas) so a drawn stroke never gets hijacked into a page-scroll -
   this is the fix for "drawing moves the screen around" on phones/tablets. */
.annotate-page-wrap .draw-canvas { touch-action: none; }

.annotate-fullscreen-btn { margin-left: auto; }
.annotate-mobile-tip { font-size: 0.85rem; color: var(--color-text-light); margin: -0.4em 0 1em; }
.annotate-workspace.is-fullscreen .annotate-mobile-tip { display: none; }
.annotate-btn-icon { display: inline-block; }
.annotate-tool .annotate-btn-icon, .annotate-toolbar .btn .annotate-btn-icon { margin-right: 0.4em; }
.annotate-pager .btn .annotate-btn-icon { margin: 0 0.4em; }

/* ---- Fullscreen drawing mode --------------------------------------------- */
/* The whole point of fullscreen is to hand the PDF as much of the screen as
   possible. Rather than reserving a permanent column for drawing tools - real
   width lost on a phone even while the tools sit idle - they live in a small
   floating, draggable FAB that expands into a compact panel on tap and folds
   away again afterwards. The canvas simply takes the entire remaining area. */
.annotate-workspace.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #fff;
    margin: 0;
    padding: 0.35em;
    display: flex;
    flex-direction: column;
}
.annotate-workspace.is-fullscreen .annotate-btn-label {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}
.annotate-workspace.is-fullscreen .annotate-tool .annotate-btn-icon,
.annotate-workspace.is-fullscreen .annotate-toolbar .btn .annotate-btn-icon,
.annotate-workspace.is-fullscreen .annotate-pager .btn .annotate-btn-icon,
.annotate-workspace.is-fullscreen .annotate-output-actions .btn .annotate-btn-icon {
    margin: 0;
}

/* The FAB itself - hidden outside fullscreen, otherwise fixed-positioned so
   annotate.js can drag it freely via inline left/top (clamped in JS to stay
   clear of the bottom safe-zone and off the pager strip at the top). */
.annotate-fab {
    display: none;
    position: fixed;
    top: 4.5em;
    right: 0.6em;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    box-shadow: var(--shadow-hover);
    z-index: 1002;
    touch-action: none;
    cursor: grab;
}
.annotate-workspace.is-fullscreen .annotate-fab {
    display: flex;
    align-items: center;
    justify-content: center;
}
.annotate-fab:active { cursor: grabbing; }

/* The toolbar and output-actions become two small floating cards, positioned
   by annotate.js (positionFloatingPanel()) relative to the FAB's current spot -
   hidden entirely until the FAB is tapped open (.toolbar-open on the workspace). */
.annotate-workspace.is-fullscreen .annotate-toolbar,
.annotate-workspace.is-fullscreen .annotate-output-actions {
    display: none;
    position: fixed;
    z-index: 1001;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 0.5em;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;
    gap: 0.35em;
    width: 168px;
    max-height: 45vh;
    overflow-y: auto;
    margin: 0;
}
.annotate-workspace.is-fullscreen.toolbar-open .annotate-toolbar,
.annotate-workspace.is-fullscreen.toolbar-open .annotate-output-actions {
    display: flex;
}
.annotate-workspace.is-fullscreen .annotate-tool,
.annotate-workspace.is-fullscreen .annotate-toolbar .btn,
.annotate-workspace.is-fullscreen .annotate-output-actions .btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}
.annotate-workspace.is-fullscreen .annotate-width-label {
    font-size: 0;
    gap: 0.2em;
    flex-direction: column;
    width: 44px;
}
.annotate-workspace.is-fullscreen .annotate-width-label input[type="range"] { width: 44px; }
.annotate-workspace.is-fullscreen input[type="color"] { width: 32px; height: 32px; padding: 0; flex-shrink: 0; }

.annotate-workspace.is-fullscreen .annotate-pager {
    position: relative;
    justify-content: center;
    gap: 0.5em;
    margin-bottom: 0.3em;
    flex-shrink: 0;
}
.annotate-workspace.is-fullscreen .annotate-pager .btn { padding: 0.3em 0.5em; }
.annotate-workspace.is-fullscreen #annotatePageStatus { font-size: 0.85rem; }

/* Dedicated one-tap exit, pinned to the top-right of the page-nav bar - the
   floating-panel Fullscreen button still works too, but shouldn't be the only
   way out of fullscreen when you're not already holding it open. */
.annotate-pager-exit-btn {
    display: none;
    position: absolute;
    top: 50%;
    right: 0.2em;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-light);
    font-size: 0.8rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}
.annotate-workspace.is-fullscreen .annotate-pager-exit-btn { display: block; }
.annotate-pager-exit-btn:hover { color: var(--color-text); border-color: var(--color-primary); }

.annotate-workspace.is-fullscreen .annotate-canvas-stack {
    flex: 1;
    min-height: 0;
    min-width: 0;
    margin-bottom: 0;
    padding: 0.4em;
    /* Top-anchor the page rather than centering it, so the safe-zone height reserved in
       computeFitScale() (FULLSCREEN_BOTTOM_SAFE_ZONE in annotate.js) lands entirely as a
       real gap at the bottom - not split evenly above and below - keeping drawn content
       out of the strip where iOS intercepts touches for its own home-indicator swipe. */
    align-items: flex-start;
}

.annotate-workspace.is-fullscreen .annotate-status-msg {
    font-size: 0.65rem;
    text-align: center;
    max-width: 150px;
}
body.annotate-fullscreen-lock { overflow: hidden; }
.annotate-text-input {
    position: absolute;
    z-index: 5;
    border: 1px dashed var(--color-primary);
    background: rgba(255, 255, 255, 0.85);
    padding: 2px 4px;
    font-family: sans-serif;
    min-width: 120px;
}
.annotate-output-actions { display: flex; align-items: center; gap: 1em; flex-wrap: wrap; margin-top: 1.2em; }
.annotate-status-msg { color: var(--color-text-light); font-size: 0.9rem; }

/* ---- Sidebar / ad slots -------------------------------------------------- */
.page-sidebar { display: none; }
.ad-slot {
    background: #fdfaf4;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
    font-size: 0.8rem;
}
.ad-slot-label { text-transform: uppercase; letter-spacing: 0.05em; }
.ad-slot--sidebar { min-height: 600px; width: 100%; }
.ad-slot--infeed { grid-column: span 1; min-height: 250px; }
.ad-slot--footer { min-height: 90px; margin: 2em auto 1.5em; max-width: var(--max-width); }

/* ---- Forms --------------------------------------------------------------- */
.admin-form, .simple-form {
    display: flex;
    flex-direction: column;
    gap: 0.3em;
    max-width: 520px;
}
.admin-form label, .simple-form label {
    font-weight: 600;
    margin-top: 0.8em;
}
.admin-form input[type=text],
.admin-form input[type=email],
.admin-form input[type=password],
.admin-form input[type=number],
.admin-form input[type=file],
.admin-form select,
.admin-form textarea,
.simple-form input[type=text],
.simple-form input[type=email],
.simple-form textarea {
    padding: 0.6em 0.8em;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
}
.admin-form button, .simple-form button { margin-top: 1.3em; align-self: flex-start; }
.hp-field { position: absolute; left: -9999px; }
.form-privacy-note { font-size: 0.85rem; color: var(--color-text-light); margin-top: 0.6em; }
/* ---- Pagination ----------------------------------------------------------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 1.5em; margin: 2em 0; }

/* ---- Footer --------------------------------------------------------------- */
.site-footer {
    background: #2f3e46;
    color: #d7dee2;
    margin-top: 2em;
}
.site-footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2.5em 1.5em;
    display: flex;
    flex-wrap: wrap;
    gap: 2em;
    justify-content: space-between;
}
.site-footer-brand strong { color: #fff; font-family: var(--font-heading); font-size: 1.2rem; }
.site-footer-nav { display: flex; flex-direction: column; gap: 0.5em; }
.site-footer-nav a { color: #d7dee2; }
.site-footer-nav a:hover { color: #fff; }
.site-footer-copy { width: 100%; text-align: center; color: #9aa7ac; font-size: 0.85rem; margin: 1.5em 0 0; }

/* ---- Responsive ------------------------------------------------------------ */
@media (min-width: 1024px) {
    .page-layout { grid-template-columns: 1fr 300px; }
    .page-sidebar { display: block; }
}

@media (max-width: 780px) {
    .nav-toggle { display: flex; }
    .site-nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.8em;
        padding-top: 0.8em;
    }
    .site-nav.is-open { display: flex; }
    .nav-search { width: 100%; }
    .nav-search input { flex: 1; }
}
