/* ==========================================================================
   SkillzForge — Responsive Styles
   Mobile-first breakpoints
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tablet (≥ 640px)
   -------------------------------------------------------------------------- */
@media (min-width: 640px) {
    :root {
        --sf-header-h: 110px;
    }

    .skill-card__actions {
        flex-wrap: wrap;
    }
}

/* --------------------------------------------------------------------------
   Desktop (≥ 1024px)
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
    :root {
        --sf-header-h: 110px;
    }

    .main-content {
        padding: 32px 24px 64px;
    }

    .groups-container {
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    }

    .achievement-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
}

/* --------------------------------------------------------------------------
   Mobile (< 640px) — primary target
   -------------------------------------------------------------------------- */
@media (max-width: 639px) {
    :root {
        --sf-header-h:  110px;
        --sf-xp-bar-h:  33px;   /* 5 px taller than desktop */
        --sf-nav-h:     0px;    /* Nav collapses to hamburger */
        --sf-font-size: 12px;
        --sf-font-size-lg: 14px;
    }

    /* Hide static seasonal weather sprite — too noisy on small screens */
    #weatherOverlay { display: none; }

    /* XP bar sits above the header — header pushed down */
    .site-header {
        top: var(--sf-xp-bar-h);
    }
    

    body {
        padding-top: calc(var(--sf-xp-bar-h) + var(--sf-header-h));
    }

    /* XP bar — full-width strip at very top of viewport */
    .xp-bar-wrapper {
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: var(--sf-xp-bar-h);
        padding: 0;
        background: var(--sf-surface);
        border-top: none;
        border-right: none;
        border-bottom: 2px solid var(--sf-primary);
        border-left: none;
        border-radius: 0;
        backdrop-filter: none;
        z-index: 1000;
    }

    .xp-bar-profile-link:hover {
        opacity: 0.85;
    }

    .xp-bar-inner {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        width: 100%;
        padding: 0 8px 0 45px; /* left gap clears the hamburger button */
    }

    .xp-track  { display: block; }
    .xp-total  { display: none; }

    .xp-label {
        font-size: 7px;
        min-width: 0;
    }

    .xp-numbers {
        font-size: 6px;
    }

    /* Hamburger — inline with XP bar at top of viewport */
    .nav-hamburger {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: auto;
        width: 41px;
        height: var(--sf-xp-bar-h);
        padding: 0;
        background: transparent;
        backdrop-filter: none;
        border: none;
        border-right: 1px solid var(--sf-border);
        border-radius: 0;
        z-index: 3100;
        justify-content: center;
        align-items: center;
    }

    .nav-hamburger .hamburger-line {
        width: 16px;
    }

    .site-nav {
        top: 0;
        height: 0;
        width: 0;
        z-index: 3100;
    }

    .nav-list {
        position: fixed;
        top: calc(var(--sf-xp-bar-h) + var(--sf-header-h));
        left: 0;
        right: 0;
        background: var(--sf-surface);
        border-bottom: 2px solid var(--sf-primary);
        flex-direction: column;
        align-items: stretch;
        height: auto;
        padding: 8px;
        display: none;
        z-index: 3100;
    }

    .nav-list.nav--open {
        display: flex;
    }

    .nav-link {
        padding: 10px 12px;
        border-radius: var(--sf-radius);
        width:200px;
    }

    .nav-link--logout { margin-left: 0; }

    /* Header compact */
    .site-title { font-size: 11px !important; }

    /* Landscape image: on narrow screens the proportional height (width × aspect ratio)
       can fall below the header height. min-height: 100% guarantees the image box
       fills the full header height (100% of .landscape-wrapper which has inset:0).
       object-fit: cover prevents distortion when min-height forces the box taller
       than the natural proportional height, filling the box by cropping instead.
       scale: 1.5 then magnifies the already-covering image for the drag bleed. */
    .landscape-layer {
        scale: 1.5;
        translate: 0 calc(-50% + 12%);
        min-height: 100%;
        object-fit: cover;
    }

    .header-controls {
        gap: 6px;
    }

    /* Dashboard */
    .dashboard-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .groups-container {
        grid-template-columns: 1fr;
    }

    .skill-card__actions {
        gap: 4px;
    }

    /* Forms */
    .group-select-row {
        flex-direction: column;
    }

    .group-select-row select { width: 100%; }

    .form-actions {
        flex-direction: column;
    }

    /* Achievements */
    .achievement-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }

    /* Practice history table — stack columns */
    .history-table thead { display: none; }

    .history-table td {
        display: block;
        padding: 4px 8px;
    }

    .history-table td::before {
        content: attr(data-label) ': ';
        font-family: var(--sf-font-pixel);
        font-size: 10px;
        color: var(--sf-text-muted);
    }

    .history-table tr {
        display: flex;
        flex-wrap: wrap;
        border-bottom: 2px solid var(--sf-border);
        margin-bottom: 12px;
    }

    /* All cells stretch full width except the action pair */
    .history-table td {
        flex: 1 1 100%;
    }

    /* Edit and Delete cells sit side-by-side at the bottom of each row */
    .history-table td.session-edit-cell,
    .history-table td.session-delete-cell {
        flex: 1 1 auto;
        order: 99;
        width: auto;
        white-space: nowrap;
        padding: 6px 8px;
    }

    /* Suppress the auto-generated label prefix on action cells */
    .history-table td.session-edit-cell::before,
    .history-table td.session-delete-cell::before {
        content: none;
    }

    /* Date cell — show label prefix for context */
    .history-table td.session-date::before {
        content: 'Date: ';
    }

    /* Photos cell — thumbnails and add button stack vertically */
    .history-table td[data-label="Photos"]::before {
        display: block;
        margin-bottom: 4px;
    }

    .session-photos-add { margin-top: 6px; }

    /* Upload section wraps to next line on narrow cards */
    .upload-section { flex-direction: row; }

    /* Larger touch target for photo thumbs on mobile */
    .session-photo-thumb {
        width: 72px;
        height: 72px;
    }

    /* Reminder container */
    .reminder-container {
        left: 10px;
        right: 10px;
        max-width: none;
        bottom: 10px;
    }

    /* Skill stats row */
    .skill-stats {
        grid-template-columns: 1fr 1fr;
        display: grid;
    }

    /* Profile grid */
    .profile-grid { grid-template-columns: 1fr; }

    /* Share buttons */
    .share-buttons { flex-direction: column; }
    .share-btn { width: 100%; }
}

/* --------------------------------------------------------------------------
   Print styles — hide UI chrome
   -------------------------------------------------------------------------- */
@media print {
    .xp-bar-wrapper,
    .site-header,
    .site-nav,
    .skill-card__actions,
    .pixel-btn,
    .reminder-container,
    .news-dialog,
    .sf-modal {
        display: none !important;
    }

    body {
        padding-top: 0;
        background: white;
        color: black;
    }
}

/* --------------------------------------------------------------------------
   Reduced motion accessibility
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}