/* ============================================================
   Garmin Apps Portfolio — main stylesheet
   Mobile-first. Breakpoints: 640px (tablet), 1024px (desktop).
   ============================================================ */

:root {
    --c-bg:           #0e1116;
    --c-bg-soft:      #161b22;
    --c-surface:      #1c232c;
    --c-border:       #2a323d;
    --c-text:         #e6edf3;
    --c-text-soft:    #9ba8b6;
    --c-text-dim:     #6e7a89;
    --c-accent:       #00a4e4;       /* Garmin-style blue */
    --c-accent-hover: #1cb6f3;
    --c-success:      #2ea043;
    --c-danger:       #f85149;
    --c-warn:         #d29922;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
    --shadow:    0 4px 12px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, .45);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    --font:       system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono:  ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--c-accent); text-decoration: none; }
a:hover, a:focus { color: var(--c-accent-hover); text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--space-4); font-weight: 700; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 var(--space-4); }

/* ---------- Layout ---------- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

main {
    padding: var(--space-6) 0 var(--space-8);
    min-height: 60vh;
}

/* ---------- Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(14, 17, 22, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--c-border);
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    max-width: 1100px;
    margin: 0 auto;
}
.brand {
    color: var(--c-text);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: .3px;
}
.brand:hover { text-decoration: none; color: var(--c-text); }
.brand__dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--c-accent);
    margin-right: var(--space-2);
    transform: translateY(-1px);
}

.nav-toggle {
    background: transparent;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    color: var(--c-text);
    padding: 6px 10px;
    font-size: 1.2rem;
    line-height: 1;
}

.nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--c-bg-soft);
    border-bottom: 1px solid var(--c-border);
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
    gap: var(--space-3);
}
.nav.is-open { display: flex; }
.nav a {
    color: var(--c-text);
    padding: var(--space-2) 0;
    font-weight: 500;
}
.nav a.is-active { color: var(--c-accent); }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--c-border);
    background: var(--c-bg-soft);
    color: var(--c-text-soft);
    padding: var(--space-6) 0;
    font-size: .9rem;
}
.site-footer__inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    text-align: center;
}
.site-footer a { color: var(--c-text-soft); }
.site-footer a:hover { color: var(--c-accent); }

/* ---------- Hero ---------- */
.hero {
    padding: var(--space-7) 0 var(--space-6);
    text-align: center;
    background:
        radial-gradient(800px 400px at 50% -10%, rgba(0, 164, 228, .18), transparent 60%),
        var(--c-bg);
    border-bottom: 1px solid var(--c-border);
}
.hero h1 {
    font-size: 2rem;
    margin-bottom: var(--space-3);
}
.hero p.lead {
    color: var(--c-text-soft);
    font-size: 1.05rem;
    max-width: 640px;
    margin: 0 auto var(--space-5);
}
.hero__cta {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background .15s, border-color .15s, color .15s;
    text-decoration: none;
    cursor: pointer;
}
.btn--primary {
    background: var(--c-accent);
    color: #fff;
}
.btn--primary:hover, .btn--primary:focus {
    background: var(--c-accent-hover);
    color: #fff;
    text-decoration: none;
}
.btn--ghost {
    background: transparent;
    border-color: var(--c-border);
    color: var(--c-text);
}
.btn--ghost:hover {
    border-color: var(--c-accent);
    color: var(--c-accent);
    text-decoration: none;
}
.btn--danger {
    background: var(--c-danger);
    color: #fff;
}
.btn--small { padding: 6px 12px; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Section heading ---------- */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}
.section-head h2 { margin: 0; }
.section-head .filters {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* ---------- Filter pill ---------- */
.pill {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    color: var(--c-text-soft);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: .85rem;
    cursor: pointer;
}
.pill.is-active {
    color: #fff;
    background: var(--c-accent);
    border-color: var(--c-accent);
}

/* ---------- App grid ---------- */
.app-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
}

.app-card {
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .15s, border-color .15s, box-shadow .15s;
    color: inherit;
}
.app-card:hover {
    transform: translateY(-2px);
    border-color: var(--c-accent);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
}
.app-card__img {
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, #1b2330, #0f141b);
    object-fit: cover;
    width: 100%;
}
.app-card__body {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex: 1;
}
.app-card__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--c-text);
}
.app-card__type {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--c-accent);
    font-weight: 700;
}
.app-card__desc {
    color: var(--c-text-soft);
    font-size: .92rem;
    flex: 1;
}
.app-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--c-text-dim);
    font-size: .82rem;
    padding-top: var(--space-2);
    border-top: 1px solid var(--c-border);
}

/* ---------- App detail ---------- */
.app-hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}
.app-hero__image-wrap {
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.app-hero__image-wrap img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}
.app-hero__title { font-size: 1.9rem; margin-bottom: var(--space-2); }
.app-hero__tag {
    display: inline-block;
    background: var(--c-surface);
    color: var(--c-accent);
    border: 1px solid var(--c-border);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: var(--space-3);
}
.app-hero__rating {
    color: var(--c-warn);
    font-weight: 600;
    margin-bottom: var(--space-3);
}
.app-hero__rating span.count {
    color: var(--c-text-dim);
    font-weight: 400;
    margin-left: var(--space-2);
}
.app-hero__links {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-4);
}

.spec-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
}
.spec-grid dt {
    color: var(--c-text-dim);
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .8px;
    font-weight: 600;
}
.spec-grid dd { margin: 0 0 var(--space-2); color: var(--c-text); }

.gallery {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}
.gallery img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
}

.video-wrap {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    margin-bottom: var(--space-6);
    background: #000;
}
.video-wrap iframe,
.video-wrap video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ---------- Forms ---------- */
.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-width: 640px;
}
.form__row { display: flex; flex-direction: column; gap: var(--space-1); }
.form__label {
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--c-text-soft);
    font-weight: 600;
}
.form__input, .form__textarea, .form__select {
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    width: 100%;
}
.form__input:focus,
.form__textarea:focus,
.form__select:focus {
    border-color: var(--c-accent);
    outline: 2px solid rgba(0, 164, 228, .25);
    outline-offset: 0;
}
.form__textarea { min-height: 120px; resize: vertical; }
.form__help { font-size: .8rem; color: var(--c-text-dim); }
.form__honey { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.rating-input {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 4px;
}
.rating-input input { display: none; }
.rating-input label {
    cursor: pointer;
    color: var(--c-text-dim);
    font-size: 1.6rem;
    line-height: 1;
}
.rating-input label:hover,
.rating-input label:hover ~ label,
.rating-input input:checked ~ label {
    color: var(--c-warn);
}

/* ---------- Alerts ---------- */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid;
    font-size: .92rem;
}
.alert--ok    { background: rgba(46, 160, 67, .12);  color: #7ee787; border-color: rgba(46, 160, 67, .4); }
.alert--err   { background: rgba(248, 81, 73, .12);  color: #ff9897; border-color: rgba(248, 81, 73, .4); }
.alert--info  { background: rgba(0, 164, 228, .12);  color: #79d5fb; border-color: rgba(0, 164, 228, .4); }
.alert--warn  { background: rgba(210, 153, 34, .12); color: #f0c674; border-color: rgba(210, 153, 34, .4); }

/* ---------- Comments ---------- */
.comments-list { display: flex; flex-direction: column; gap: var(--space-4); }
.comment {
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: var(--space-4);
}
.comment__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}
.comment__name { font-weight: 700; }
.comment__date { color: var(--c-text-dim); font-size: .82rem; }
.comment__rating { color: var(--c-warn); font-size: .92rem; }
.comment__body { color: var(--c-text); white-space: pre-wrap; word-wrap: break-word; }

/* ---------- Skeleton / loading ---------- */
.is-loading {
    color: var(--c-text-dim);
    text-align: center;
    padding: var(--space-6);
}
.is-empty {
    color: var(--c-text-dim);
    text-align: center;
    padding: var(--space-5);
    border: 1px dashed var(--c-border);
    border-radius: var(--radius);
}

/* ---------- Admin ---------- */
.admin-panel { display: flex; flex-direction: column; gap: var(--space-6); }
.admin-card {
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: var(--space-4);
}
.admin-card__actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

/* ---------- Prose (docs, about) ---------- */
.prose { max-width: 760px; }
.prose h2 { margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }
.prose code {
    font-family: var(--font-mono);
    font-size: .92em;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    padding: 1px 6px;
}
.prose pre {
    font-family: var(--font-mono);
    background: var(--c-bg-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: var(--space-4);
    overflow-x: auto;
    font-size: .9rem;
    line-height: 1.5;
}
.prose pre code {
    background: transparent;
    border: 0;
    padding: 0;
}
.prose blockquote {
    margin: 0 0 var(--space-4);
    padding: var(--space-2) var(--space-4);
    border-left: 3px solid var(--c-accent);
    color: var(--c-text-soft);
}
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-4);
}
.prose th, .prose td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--c-border);
}
.prose th { color: var(--c-text-soft); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .5px; }
.prose img { border-radius: var(--radius); border: 1px solid var(--c-border); margin: var(--space-3) 0; }

/* ---------- Utility ---------- */
.text-soft { color: var(--c-text-soft); }
.text-dim  { color: var(--c-text-dim); }
.mt-0 { margin-top: 0; }
.mt-3 { margin-top: var(--space-3); }
.mt-5 { margin-top: var(--space-5); }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }

/* ============================================================
   Tablet & up — 640px
   ============================================================ */
@media (min-width: 640px) {
    h1 { font-size: 2rem; }
    .hero h1 { font-size: 2.4rem; }
    .app-grid { grid-template-columns: repeat(2, 1fr); }
    .gallery   { grid-template-columns: repeat(2, 1fr); }
    .spec-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-5); }
    .spec-grid dd { margin-bottom: 0; }
}

/* ============================================================
   Desktop — 1024px
   ============================================================ */
@media (min-width: 1024px) {
    h1 { font-size: 2.25rem; }
    main { padding: var(--space-7) 0 var(--space-8); }

    .nav-toggle { display: none; }
    .nav {
        display: flex;
        position: static;
        flex-direction: row;
        gap: var(--space-5);
        background: transparent;
        border: 0;
        padding: 0;
    }
    .nav a { padding: 0; }

    .app-grid { grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
    .gallery  { grid-template-columns: repeat(3, 1fr); }

    .app-hero { grid-template-columns: 1fr 1fr; align-items: start; }
    .site-footer__inner {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
