/* Whisky App 2026 design. Loaded after the jQuery Mobile structure CSS;
   jQuery Mobile is only used for page switching, all widgets are native. */

:root {
    --bg: #f4f1e8;
    --surface: #ffffff;
    --text: #18392e;
    --muted: #616d65;
    --line: #dae2d8;
    --soft: #edf3eb;
    --active: #215a42;
    --on-active: #f4f1e8;
    --amber: #ad5c10;
    --glass-line: #a5ada0;
    --barley: #8f773e;
    --grain-a: #5c4b2920;
    --grain-b: #886e4214;
    --card-grain: #8e775c0e;
    --glow: #c99e4620;
    --shadow: #614c2810;
    --trait-singlemalt: #2b7449;
    --trait-caskstrength: #bc5a24;
    --trait-singlecask: #9c6213;
    --trait-chillfiltered: #39799c;
    --nav-height: 64px;
    --serif: Georgia, "Times New Roman", serif;
    --sans: Arial, "Helvetica Neue", Helvetica, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #151e1b;
        --surface: #202c27;
        --text: #f2f0e7;
        --muted: #b5c3b9;
        --line: #3a4b40;
        --soft: #293b30;
        --active: #aed3ad;
        --on-active: #151e1b;
        --amber: #efb35f;
        --glass-line: #75897b;
        --barley: #c7ad70;
        --grain-a: #d9c99612;
        --grain-b: #cab58a0b;
        --card-grain: #dac8a509;
        --glow: #b8a25d0d;
        --shadow: #00000015;
        --trait-singlemalt: #8ec99b;
        --trait-caskstrength: #eea16e;
        --trait-singlecask: #e1b65f;
        --trait-chillfiltered: #88bfdf;
        color-scheme: dark;
    }
}

/* ---------- base ---------- */

html, body {
    margin: 0;
    background: var(--bg);
}

body,
.ui-mobile,
.ui-mobile body {
    font-family: var(--sans);
    font-size: 16px;
    color: var(--text);
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

*, *:before, *:after {
    box-sizing: border-box;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-align: inherit;
}

a {
    color: var(--active);
}

:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
}

h1, h2 {
    font-family: var(--serif);
    font-weight: 500;
    margin: 0;
}

h1 {
    font-size: 1.65rem;
    line-height: 1.2;
}

h2 {
    font-size: 1.3rem;
}

p {
    margin: 0 0 .8em;
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

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

[hidden] {
    display: none !important;
}

/* ---------- background: paper grain and barley ---------- */

body {
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse at 95% 18%, var(--glow), transparent 64%),
        radial-gradient(var(--grain-a) .55px, transparent .8px),
        radial-gradient(var(--grain-b) .5px, transparent .8px);
    background-size: auto, 5px 7px, 9px 11px;
    background-position: 0 0, 0 0, 3px 4px;
    background-attachment: fixed;
}

.barley-watermark {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    color: var(--barley);
    opacity: .30;
}

.barley-watermark svg {
    position: absolute;
    width: 230px;
    height: 390px;
    fill: color-mix(in srgb, currentColor 22%, transparent);
    stroke: currentColor;
    stroke-width: .65;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.barley-watermark svg:nth-child(1) { right: -90px; top: 120px; transform: rotate(-24deg); }
.barley-watermark svg:nth-child(2) { left: -105px; top: 52%; transform: rotate(23deg); width: 210px; height: 355px; }
.barley-watermark svg:nth-child(3) { right: -105px; bottom: -120px; transform: rotate(-19deg); width: 250px; height: 410px; }

/* ---------- app shell ---------- */

.app-shell {
    position: relative;
    z-index: 1;
    max-width: 1240px;
    margin: 0 auto;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* jQuery Mobile pages flow inside the shell instead of being absolutely positioned */
.ui-mobile .app-pages [data-role=page],
.ui-mobile .app-pages .ui-page {
    position: relative;
    min-height: 0 !important;
    background: transparent;
    padding: 18px 16px 8px;
    border: 0;
}

.ui-mobile-viewport {
    background: transparent;
}

/* jQuery Mobile focuses the page container after a page change */
.ui-page:focus,
.ui-page:focus-visible {
    outline: none;
}

.ui-loader {
    display: none !important;
}

/* ---------- photo header ---------- */

.hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: #173c30;
    color: #fff4d9;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 20px;
}

.hero-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 48%;
    z-index: -2;
}

.hero:after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #102b24f5, #15372a93);
    z-index: -1;
}

.hero-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    font: 500 1.7rem var(--serif);
    letter-spacing: -1px;
    color: #fff4d9;
    text-decoration: none;
}

.logo span {
    color: #efbc65;
}

.tagline {
    font-size: .8rem;
    color: #d1dbc9;
    margin: 6px 0 0;
}

.profile-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid #ffffff50;
    border-radius: 50%;
    color: #fff4d9;
}

/* ---------- bottom navigation ---------- */

.app-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    justify-content: center;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}

.app-nav a {
    display: flex;
    flex: 1;
    max-width: 150px;
    min-width: 0;
    min-height: 52px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 1px;
    font-size: .7rem;
    color: var(--muted);
    text-decoration: none;
    border-radius: 10px;
}

.app-nav a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav a[aria-current=page] {
    color: var(--active);
    font-weight: bold;
}

/* ---------- page headings and generic blocks ---------- */

.heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin: 0 4px 14px;
}

.count {
    font-size: .75rem;
    color: var(--muted);
}

.intro {
    margin: -6px 4px 14px;
    font-size: .85rem;
    color: var(--muted);
}

.panel {
    background: var(--surface);
    background-image: radial-gradient(var(--card-grain) .6px, transparent .8px);
    background-size: 6px 7px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    box-shadow: 0 2px 5px var(--shadow);
}

.panel p {
    font-size: .85rem;
    color: var(--muted);
}

.overline {
    color: var(--amber);
    font-size: .68rem;
    letter-spacing: 1.7px;
    text-transform: uppercase;
    margin-bottom: 7px;
}

.empty,
.status-text {
    padding: 18px 6px;
    font-size: .9rem;
    color: var(--muted);
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .85rem;
    min-height: 44px;
    padding: 0 4px 6px 0;
    color: var(--text);
}

.primary,
.secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    border-radius: 9px;
    padding: 12px 14px;
    font-size: .9rem;
    text-decoration: none;
}

.primary {
    background: var(--active);
    color: var(--on-active);
    margin-top: 14px;
}

.secondary {
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--text);
    margin: 10px 0;
}

.secondary[aria-pressed=true] {
    border-color: var(--active);
    color: var(--active);
    background: var(--soft);
}

.button-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0 10px;
}

.feedback {
    font-size: .85rem;
    color: var(--active);
    margin-top: 10px;
    min-height: 1.2em;
}

.feedback.error {
    color: #b3261e;
}

/* ---------- search and filters ---------- */

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 4px;
    margin-bottom: 12px;
}

.segmented button {
    min-height: 40px;
    border-radius: 8px;
    font-size: .85rem;
    text-align: center;
    color: var(--muted);
}

.segmented button[aria-pressed=true] {
    background: var(--surface);
    color: var(--text);
    font-weight: bold;
    box-shadow: 0 1px 3px var(--shadow);
}

.search {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 0 13px;
    color: var(--muted);
}

.search input {
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    outline: 0;
    color: var(--text);
    padding: 13px 0;
    font-size: 1rem;
}

.filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 11px 0 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 8px;
    padding: 6px 11px;
    font-size: .8rem;
}

.chip[aria-pressed=true] {
    background: var(--active);
    border-color: var(--active);
    color: var(--on-active);
}

.chip .icon {
    width: 16px;
    height: 16px;
}

.advanced {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 8px 0;
}

.field label,
.field-label {
    display: block;
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.field input,
.field select,
textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 11px 12px;
    color: var(--text);
    font-size: 1rem;
}

textarea {
    min-height: 76px;
    resize: vertical;
    margin-top: 6px;
}

.icon-key {
    font-size: .72rem;
    color: var(--muted);
    margin: 6px 3px 12px;
}

/* ---------- master / detail ---------- */

.md-detail {
    display: none;
}

@media (min-width: 960px) {
    .md {
        display: grid;
        grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
        gap: 22px;
        align-items: start;
    }

    .md-detail {
        display: block;
        position: sticky;
        top: 12px;
        max-height: calc(100vh - var(--nav-height) - 24px);
        overflow-y: auto;
        border-radius: 14px;
    }

    .md-detail .detail-back {
        display: none;
    }

    .md-placeholder {
        display: grid;
        place-items: center;
        min-height: 260px;
        text-align: center;
        color: var(--muted);
    }
}

/* ---------- whisky card ---------- */

.whisky-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.whisky {
    background: var(--surface);
    background-image: radial-gradient(var(--card-grain) .6px, transparent .8px);
    background-size: 6px 7px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 5px var(--shadow);
}

.whisky.selected {
    border-color: var(--active);
    box-shadow: 0 0 0 1px var(--active), 0 2px 5px var(--shadow);
}

.card-open {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 13px;
    row-gap: 11px;
    width: 100%;
    padding: 13px;
    text-align: left;
}

/* The bottle fills its column from the top of the card to just above the rating strip. */
.card-bottle {
    position: relative;
    display: block;
    grid-column: 1;
    grid-row: 1 / 3;
    align-self: stretch;
    min-height: 112px;
}

.card-bottle img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.card-info {
    display: block;
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

.card-info .expression,
.card-info .origin {
    display: block;
}

.name-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px;
}

.name-line h3 {
    font-size: 1rem;
    font-weight: bold;
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.abv {
    font-size: .8rem;
    font-weight: bold;
    color: var(--amber);
    white-space: nowrap;
}

.expression {
    font-size: .85rem;
    margin: 3px 0;
    line-height: 1.4;
}

.origin {
    font-size: .78rem;
    color: var(--muted);
    line-height: 1.4;
}

/* ---------- traits ---------- */

.traits {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.card-open .traits {
    grid-column: 2;
    grid-row: 2;
}

.trait {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
    font-size: .64rem;
    line-height: 1.3;
    color: var(--muted);
}

.trait-symbol {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: var(--muted);
    opacity: .3;
}

.trait-symbol .icon {
    width: 22px;
    height: 22px;
    stroke-width: 1.7;
}

.trait.yes {
    color: var(--text);
}

.trait.yes .trait-symbol {
    opacity: 1;
    color: var(--icon-color);
    background: color-mix(in srgb, var(--icon-color) 15%, transparent);
}

.trait.yes .trait-symbol .icon {
    fill: color-mix(in srgb, var(--icon-color) 23%, transparent);
}

.trait[data-trait=singlemalt] { --icon-color: var(--trait-singlemalt); }
.trait[data-trait=caskstrength] { --icon-color: var(--trait-caskstrength); }
.trait[data-trait=singlecask] { --icon-color: var(--trait-singlecask); }
.trait[data-trait=chillfiltered] { --icon-color: var(--trait-chillfiltered); }

/* ---------- rating glasses ---------- */

.rating-strip {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 13px;
    border-top: 1px solid var(--line);
    background: var(--soft);
}

.rating-strip-value {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
}

.rating-caption {
    font-size: .72rem;
    color: var(--muted);
}

.glasses {
    display: flex;
    gap: 3px;
}

.glass {
    display: block;
    width: 16px;
    height: 22px;
    flex-shrink: 0;
}

.glass .glass-line {
    fill: none;
    stroke: var(--glass-line);
    stroke-width: 2;
    stroke-linejoin: round;
}

.glass .glass-stem {
    fill: var(--glass-line);
}

.glass .glass-liquid {
    fill: url(#liquid-gradient);
}

.glass-picker {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    padding: 4px 0;
    border-radius: 10px;
}

.glass-picker .glass {
    width: 18%;
    max-width: 52px;
    height: auto;
    aspect-ratio: 32 / 44;
}

.glass-picker[aria-disabled=true] {
    cursor: default;
    opacity: .55;
}

.rating-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    font-size: .9rem;
}

.rating-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--amber);
    white-space: nowrap;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}

.stepper button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 9px;
}

.hint {
    font-size: .75rem;
    color: var(--muted);
    line-height: 1.5;
    margin-top: 9px;
}

/* ---------- detail ---------- */

.detail-top {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    padding: 8px 4px 4px;
}

.detail-bottle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 170px;
    padding: 0;
}

.detail-bottle img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.detail-top h1 {
    font-size: 1.6rem;
    overflow-wrap: anywhere;
}

.detail-top .expression {
    font-size: .95rem;
}

.brand-logo {
    display: block;
    max-width: 120px;
    max-height: 44px;
    margin-top: 8px;
    object-fit: contain;
}

.stats {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 6px 14px;
    margin: 0;
    font-size: .88rem;
}

.stats dt {
    color: var(--muted);
}

.stats dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.stats .glasses {
    display: inline-flex;
    vertical-align: middle;
    margin-right: 6px;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    margin: 18px 0 6px;
}

.tabs button {
    flex: 1;
    min-height: 46px;
    font-size: .85rem;
    text-align: center;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}

.tabs button[aria-selected=true] {
    border-bottom-color: var(--amber);
    color: var(--text);
    font-weight: bold;
}

.note-label {
    display: flex;
    gap: 9px;
    align-items: center;
    font-size: .9rem;
    font-weight: bold;
    margin-top: 16px;
}

.note-label span {
    color: var(--muted);
    font-weight: normal;
    font-size: .8rem;
}

.note-group h3 {
    display: flex;
    gap: 9px;
    align-items: center;
    font-size: .95rem;
    margin: 18px 0 6px;
}

.note-group h3 span {
    color: var(--muted);
    font-weight: normal;
    font-size: .8rem;
}

.note-list .taster {
    font-size: .78rem;
    font-weight: bold;
    color: var(--amber);
    margin-top: 10px;
}

.note-list .note {
    font-size: .88rem;
    line-height: 1.55;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.note-list .notesadd {
    display: none;
}

/* ---------- advice and library ---------- */

.link-list {
    display: grid;
    gap: 9px;
    margin-top: 14px;
}

.link-tile {
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
    min-height: 64px;
    padding: 13px 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    background-image: radial-gradient(var(--card-grain) .6px, transparent .8px);
    background-size: 6px 7px;
    border-radius: 10px;
    box-shadow: 0 2px 5px var(--shadow);
    color: var(--text);
    text-decoration: none;
    text-align: left;
}

.topic-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 9px;
    color: var(--active);
    background: var(--soft);
    overflow: hidden;
}

.topic-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topic-copy {
    flex: 1;
    min-width: 0;
}

.topic-copy strong {
    display: block;
    font-size: .92rem;
    font-weight: bold;
}

.topic-copy small {
    display: block;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.45;
    margin-top: 2px;
}

.link-tile > .icon {
    width: 16px;
    color: var(--muted);
}

.tip {
    background: var(--soft);
    border-left: 3px solid var(--amber);
    padding: 12px;
    font-size: .85rem;
    line-height: 1.6;
    border-radius: 0 8px 8px 0;
}

.advice-results {
    margin-top: 18px;
}

.article-text {
    max-width: 720px;
}

.article-text h1 {
    margin: 4px 0 14px;
}

.article-text p {
    font-size: .95rem;
    line-height: 1.75;
}

/* ---------- forms (add whisky) ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin: 14px 0 4px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    font-size: .88rem;
}

.check input {
    width: 20px;
    height: 20px;
    accent-color: var(--active);
}

/* ---------- bottom sheet dialogs ---------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: #0a120f99;
}

.sheet {
    width: 100%;
    max-width: 520px;
    max-height: 88vh;
    overflow-y: auto;
    background: var(--bg);
    color: var(--text);
    border-radius: 18px 18px 0 0;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 30px #0004;
}

@media (min-width: 600px) {
    .sheet-backdrop {
        align-items: center;
    }

    .sheet {
        border-radius: 18px;
    }
}

.sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sheet-close {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.sheet .field {
    margin-top: 10px;
}

.sheet p {
    font-size: .9rem;
}

#pwindicator {
    margin-top: 6px;
}

#pwindicator .bar {
    height: 4px;
    border-radius: 2px;
}

#pwindicator .label {
    font-size: .75rem;
    color: var(--muted);
}

.partner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    font-size: .85rem;
    color: var(--muted);
}

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