/* ==========================================================================
   GolfDrive – "yardage book"
   Scorekortspapper, klippt fairwaygrönt, sand och flaggrött. Siffror i
   kondenserad grotesk eftersom mätvärdet är produkten.
   ========================================================================== */

:root {
    --ink: #0e1f16;
    --ink-soft: #3d4f45;
    --turf: #1d6b45;
    --turf-deep: #123f28;
    --turf-light: #7bb26a;
    --paper: #e9e7da;
    --card: #fffdf5;
    --sand: #d8c79a;
    --flag: #c9433b;

    --rule: rgba(14, 31, 22, 0.14);
    --rule-strong: rgba(14, 31, 22, 0.3);

    --radius: 12px;
    --radius-sm: 8px;
    --shell: 580px;
    --tabbar: 66px;

    --step-0: 1rem;
    --step-1: 1.15rem;
    --step-2: 1.45rem;
    --step-3: 1.9rem;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: var(--step-0);
    line-height: 1.5;
    /* Ingen gummi-scroll som ser trasig ut i standalone-läge */
    overscroll-behavior-y: none;
}

h1, h2, h3, .display, .dist, .rank, .stat-value {
    font-family: "Barlow Condensed", "Barlow", system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: 0.01em;
    margin: 0;
    line-height: 1.02;
}

h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p { margin: 0 0 0.9em; }

a {
    color: var(--turf);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

:focus-visible {
    outline: 3px solid var(--turf-light);
    outline-offset: 2px;
    border-radius: 4px;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ skalet */
.app {
    max-width: var(--shell);
    margin-inline: auto;
    min-height: 100svh;
    background: var(--paper);
    padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 18px);
    position: relative;
    box-shadow: 0 0 0 1px var(--rule);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
    background: var(--turf-deep);
    color: #f4f2e6;
}

.wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    font-family: "Barlow Condensed", sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: #fffdf5;
    text-decoration: none;
    letter-spacing: 0.02em;
}

.wordmark span { color: var(--turf-light); }

.topbar-user {
    font-size: 0.88rem;
    color: rgba(244, 242, 230, 0.82);
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-user a { color: #fffdf5; }

main { padding: 0 0 24px; }

.section {
    padding: 22px 18px 0;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.lede {
    color: var(--ink-soft);
    max-width: 46ch;
}

/* ------------------------------------------------------------------- hero */
.hero {
    position: relative;
    color: #fdfcf4;
    padding: 30px 18px 26px;
    background-image:
        linear-gradient(to top, rgba(9, 24, 16, 0.94) 6%, rgba(9, 24, 16, 0.35) 55%, rgba(9, 24, 16, 0.15)),
        url("../img/hero-fairway.jpg");
    background-size: cover;
    background-position: center 42%;
    min-height: 62svh;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.hero h1 {
    font-size: clamp(2.5rem, 12vw, 3.6rem);
    text-wrap: balance;
    max-width: 20ch;
}

.hero p {
    color: rgba(253, 252, 244, 0.86);
    max-width: 34ch;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}

.hero-figure {
    position: relative;
    height: 168px;
    background: url("../img/green-flag.jpg") center 60% / cover;
}

.hero-figure.links { background-image: url("../img/links-course.jpg"); }

.hero-figure-title {
    position: absolute;
    inset: auto 0 0 0;
    padding: 14px 18px;
    background: linear-gradient(to top, rgba(9, 24, 16, 0.9), transparent);
    color: #fdfcf4;
}

/* --------------------------------------------------------------- knappar */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 54px;
    padding: 0 22px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--turf);
    color: #fffdf5;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active { transform: scale(0.985); }
.btn:hover { background: #19603e; }

.btn-block { width: 100%; }

.btn-ghost {
    background: transparent;
    border-color: var(--rule-strong);
    color: var(--ink);
}

.btn-ghost:hover { background: rgba(14, 31, 22, 0.05); }

.btn-on-photo {
    background: #fffdf5;
    color: var(--ink);
}

.btn-on-photo:hover { background: #f2eee0; }

.btn-flag { background: var(--flag); }
.btn-flag:hover { background: #b23a33; }

.btn-quiet {
    min-height: 40px;
    padding: 0 14px;
    background: none;
    border: 1px solid var(--rule);
    color: var(--ink-soft);
    font-size: 0.9rem;
    border-radius: 999px;
    cursor: pointer;
}

.btn[disabled], .btn-quiet[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-provider {
    background: #fffdf5;
    color: var(--ink);
    border-color: var(--rule-strong);
}

.btn-provider svg { flex: none; }
.btn-provider.apple { background: #111; color: #fff; border-color: #111; }

/* ------------------------------------------------------------------ kort */
.card {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 18px;
}

.card + .card { margin-top: 14px; }

.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
}

.stat {
    background: var(--card);
    padding: 14px 12px;
}

.stat-value {
    font-size: 1.9rem;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--ink-soft);
}

/* ------------------------------------------------------- topplista/scorekort */
.filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 18px 12px;
    scrollbar-width: none;
}

.filters::-webkit-scrollbar { display: none; }

.chip {
    flex: none;
    min-height: 38px;
    padding: 0 15px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
}

.chip[aria-current="true"], .chip.is-active {
    background: var(--turf-deep);
    border-color: var(--turf-deep);
    color: #fffdf5;
}

.board {
    border-top: 1px solid var(--rule);
    margin: 0 0 8px;
}

.board-row {
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--rule);
    background: var(--card);
    position: relative;
}

.board-row.is-me { background: #f4f7ec; }

.board-row.is-me::after {
    content: "du";
    position: absolute;
    top: 8px;
    right: 18px;
    font-size: 0.68rem;
    color: var(--turf);
}

.board-row .rank {
    font-size: 1.5rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.board-row:nth-child(1) { border-left: 4px solid var(--flag); }
.board-row:nth-child(2) { border-left: 4px solid var(--sand); }
.board-row:nth-child(3) { border-left: 4px solid var(--turf-light); }
.board-row:nth-child(1) .rank { color: var(--flag); }

.player {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.player-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-meta {
    font-size: 0.82rem;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metres {
    font-family: "Barlow Condensed", sans-serif;
    font-weight: 700;
    font-size: 1.85rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    white-space: nowrap;
}

.metres small {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-left: 3px;
}

.empty {
    background: var(--card);
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    padding: 26px 20px;
    text-align: center;
    color: var(--ink-soft);
}

/* ------------------------------------------------------------- mätskärmen */
.measure {
    background: var(--ink);
    color: #f4f2e6;
    padding: 20px 18px 26px;
    min-height: calc(100svh - var(--tabbar) - 120px);
}

.gps-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border-radius: 999px;
    background: rgba(244, 242, 230, 0.1);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.gps-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #8b8f86;
    box-shadow: 0 0 0 0 rgba(123, 178, 106, 0.6);
}

.gps-dot.good { background: var(--turf-light); animation: pulse 2.4s ease-out infinite; }
.gps-dot.fair { background: var(--sand); }
.gps-dot.poor { background: var(--flag); }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(123, 178, 106, 0.55); }
    70% { box-shadow: 0 0 0 12px rgba(123, 178, 106, 0); }
    100% { box-shadow: 0 0 0 0 rgba(123, 178, 106, 0); }
}

.readout {
    margin: 22px 0 8px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.dist {
    font-size: clamp(4.6rem, 30vw, 8.5rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    color: #fffdf5;
}

.dist-unit {
    font-family: "Barlow Condensed", sans-serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: rgba(244, 242, 230, 0.65);
    padding-bottom: 1.1rem;
}

.readout-note {
    color: rgba(244, 242, 230, 0.7);
    font-size: 0.92rem;
    min-height: 1.4em;
}

.flight {
    width: 100%;
    height: 86px;
    margin: 6px 0 18px;
    display: block;
    overflow: visible;
}

.flight-path {
    fill: none;
    stroke: var(--turf-light);
    stroke-width: 2.5;
    stroke-dasharray: 7 9;
    stroke-linecap: round;
}

.flight-ball { fill: #fffdf5; }
.flight-ground { stroke: rgba(244, 242, 230, 0.25); stroke-width: 1; }
.flight-marker { fill: var(--flag); }

.steps {
    display: grid;
    gap: 10px;
    margin: 4px 0 20px;
    counter-reset: step;
}

.step {
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 12px;
    align-items: start;
    color: rgba(244, 242, 230, 0.55);
    font-size: 0.93rem;
}

.step::before {
    counter-increment: step;
    content: counter(step);
    font-family: "Barlow Condensed", sans-serif;
    font-weight: 700;
    text-align: center;
    border: 1px solid rgba(244, 242, 230, 0.3);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    line-height: 24px;
}

.step.is-current {
    color: #fffdf5;
}

.step.is-current::before {
    background: var(--turf-light);
    border-color: var(--turf-light);
    color: var(--ink);
}

.step.is-done::before {
    content: "✓";
    background: rgba(123, 178, 106, 0.25);
    border-color: rgba(123, 178, 106, 0.5);
    color: var(--turf-light);
}

.measure-actions {
    display: grid;
    gap: 10px;
}

.measure .field label { color: rgba(244, 242, 230, 0.72); }

.measure .field input,
.measure .field select,
.measure .field textarea {
    background: rgba(244, 242, 230, 0.07);
    border-color: rgba(244, 242, 230, 0.28);
    color: #fffdf5;
}

.measure .field select option { color: var(--ink); }

.detected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(244, 242, 230, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: rgba(244, 242, 230, 0.8);
    margin-bottom: 14px;
}

/* ---------------------------------------------------------------- formulär */
.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    font: inherit;
    font-size: 1rem; /* 16px hindrar iOS från att zooma vid fokus */
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field-hint {
    font-size: 0.8rem;
    color: var(--ink-soft);
    margin-top: 5px;
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--flag);
    background: rgba(201, 67, 59, 0.08);
    color: #7d2620;
    margin-bottom: 14px;
    font-size: 0.93rem;
}

.alert-ok {
    border-color: var(--turf);
    background: rgba(29, 107, 69, 0.08);
    color: #14512f;
}

.measure .alert { color: #ffd9d5; background: rgba(201, 67, 59, 0.16); }
.measure .alert-ok { color: #d8f0d2; background: rgba(123, 178, 106, 0.16); border-color: var(--turf-light); }

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink-soft);
    font-size: 0.85rem;
    margin: 18px 0;
}

.divider::before, .divider::after {
    content: "";
    height: 1px;
    background: var(--rule);
    flex: 1;
}

/* -------------------------------------------------------------- banlistan */
.course-list { border-top: 1px solid var(--rule); }

.course-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--rule);
    background: var(--card);
    text-decoration: none;
    color: inherit;
}

.course-row .away {
    font-size: 0.82rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.course-row.here { background: #f4f7ec; }

/* ---------------------------------------------------------------- tabbar */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, var(--shell));
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: rgba(255, 253, 245, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--rule);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 30;
}

.tab {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 9px 0 8px;
    height: var(--tabbar);
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.72rem;
}

.tab svg { width: 23px; height: 23px; stroke-width: 1.7; }

.tab[aria-current="page"] {
    color: var(--turf);
    font-weight: 600;
}

.tab[aria-current="page"] svg { stroke-width: 2.2; }

/* --------------------------------------------------------------- diverse */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 16px);
    transform: translate(-50%, 12px);
    width: min(92%, 460px);
    background: var(--ink);
    color: #fffdf5;
    border-radius: var(--radius);
    padding: 13px 16px;
    font-size: 0.94rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 40;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

footer.site {
    padding: 18px;
    color: var(--ink-soft);
    font-size: 0.82rem;
    border-top: 1px solid var(--rule);
    margin-top: 26px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (min-width: 620px) {
    .app { box-shadow: 0 0 60px rgba(14, 31, 22, 0.12); }
    .hero-actions { flex-direction: row; }
}

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