:root {
    --yellow: #FBF508;
    --cross: #d9d9d9;
    --text: #e6e6e6;
    --panel: rgba(0, 0, 0, 0.8);
    --bar: 20vmin;
    /* How far the wheel zooms in while it spins. Small in portrait, where
       the wheel already fills the width; more in landscape. */
    --zoom: 1.05;
    /* The title sets the height of the top bar */
    --title-w: min(calc(100vw - 4.5rem), 34rem);
    --bar-h: calc(var(--title-w) * 0.15 + 0.7rem);
    --wheel: min(95vw, calc((100dvh - var(--bar-h) - 4rem) / 1.04));
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: #000000;
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ---------- buttons, shared ---------- */

.btn {
    display: inline-block;
    padding: 0.5em 1em;
    border: 0.12em solid var(--yellow);
    border-radius: 2em;
    background: var(--yellow);
    color: #000000;
    font: inherit;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
}

.btn-quiet {
    background: #000000;
    color: var(--yellow);
}

/* ---------- wheel page ---------- */

.wheel-page {
    min-height: 100dvh;
    overflow-x: hidden;
}

/* The first screen: title, wheel and (after a spin) the winning pasty */
.first {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    min-height: 100dvh;
    padding: calc(var(--bar-h) + 0.6rem) 2.5vw 0.6rem;
    overflow-x: clip;   /* the zoomed wheel mustn't make the page wider than the screen */
    /* St Piran's flag, drawn in code */
    background:
        linear-gradient(var(--cross), var(--cross)) center / var(--bar) 100% no-repeat,
        linear-gradient(var(--cross), var(--cross)) center / 100% var(--bar) no-repeat,
        #000000;
}

.stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

/* Top bar: title and menu. Fixed over the page; slides away on scrolling
   down and comes back on a deliberate scroll up (bar.js), as on the DTS site. */
.bar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 10;
    border-bottom: 0.06rem solid #2a3340;
    background: #000000;
    transition: transform 0.25s ease;
}

.bar.is-hidden {
    transform: translateY(-100%);
}

@media (prefers-reduced-motion: reduce) {
    .bar {
        transition: none;
    }
}

.bar-inner {
    display: grid;
    grid-template-columns: 1fr 3rem;
    align-items: center;
    justify-items: center;
    gap: 0.5rem;
    height: var(--bar-h);
    padding: 0 0.5rem;
}

/* The title is drawn to a set width, so it always fits on one line
   and scales with the screen whatever font the device has. */
.title {
    display: block;
    width: var(--title-w);
    margin: 0;
    line-height: 0;
}

.title svg {
    display: block;
    width: 100%;
}

.title text {
    fill: var(--yellow);
    stroke: #000000;
    stroke-width: 2.2;
    stroke-linejoin: round;
    paint-order: stroke fill;
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', 'Arial Black', sans-serif;
}

.menu {
    position: relative;
    justify-self: end;
}

.menu summary {
    display: grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.6rem;
    cursor: pointer;
    list-style: none;
}

.menu summary::-webkit-details-marker {
    display: none;
}

.menu summary svg {
    width: 1.8rem;
    height: 1.8rem;
    fill: none;
    stroke: var(--yellow);
    stroke-width: 2.4;
    stroke-linecap: round;
}

.menu-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    display: grid;
    gap: 0.3rem;
    min-width: 11rem;
    padding: 0.5rem;
    border: 0.1rem solid var(--yellow);
    border-radius: 0.8rem;
    background: #000000;
    box-shadow: 0 0.8rem 1.6rem rgba(0, 0, 0, 0.8);
}

.menu-item {
    padding: 0.6em 0.8em;
    border: 0;
    border-radius: 0.5rem;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
    background: #222222;
    color: var(--yellow);
}

/* The winner: a cut-out pasty that is the "take me there" button.
   It takes up no room until there is a result, so the wheel sits central. */
.win {
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s ease, max-width 0.5s ease, opacity 0.4s ease 0.15s;
}

.stage.has-result .win {
    max-height: 16rem;
    opacity: 1;
}

.win-inner {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 1rem 0.8rem;
}

.pasty-btn {
    display: grid;
    place-items: center;
    text-decoration: none;
    filter: drop-shadow(0 0.6rem 0.7rem rgba(0, 0, 0, 0.8));
}

.pasty-btn > * {
    grid-area: 1 / 1;
}

.cut {
    display: block;
    width: auto;
    max-width: 84vw;
    height: 10.5rem;
    object-fit: contain;
}

.on-pasty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    text-align: center;
}

.result {
    color: var(--yellow);
    font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', 'Arial Black', sans-serif;
    /* Shrinks for long names so they always fit on one line (--chars is the
       name's length, set by wheel.js). Each capital is about 0.62 of the size. */
    font-size: min(clamp(2.2rem, 10vmin, 3.8rem), calc(88vw / (var(--chars, 10) * 0.62)));
    white-space: nowrap;
    letter-spacing: 0.05em;
    line-height: 1.05;
    text-transform: uppercase;
    -webkit-text-stroke: 0.16em #000000;
    paint-order: stroke fill;
    text-shadow: 0 0.1em 0.3em #000000;
}

.result.won {
    animation: won 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes won {
    from {
        transform: scale(0.2) rotate(-8deg);
        opacity: 0;
    }
}

.go-hint {
    padding: 0.25em 0.9em;
    border-radius: 2em;
    background: var(--yellow);
    color: #000000;
    font-size: 0.95rem;
    font-weight: bold;
}

/* Remove option: red X */
.remove {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    padding: 0.35em 0.9em 0.35em 0.4em;
    border: 0.12em solid #d42a2a;
    border-radius: 2em;
    background: #000000;
    color: #ffffff;
    font: inherit;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
}

.remove-x {
    display: grid;
    place-items: center;
    width: 1.6em;
    height: 1.6em;
    border-radius: 50%;
    background: #d42a2a;
    color: #ffffff;
    font-size: 0.9em;
    line-height: 1;
}

/* "Are you sure?" pop-up */
.confirm {
    padding: 1.2rem 1.4rem;
    border: 0.15rem solid var(--yellow);
    border-radius: 1rem;
    background: #000000;
    color: var(--text);
    text-align: center;
}

.confirm::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.confirm p {
    margin: 0 0 0.4rem;
    font-size: 1.3rem;
    font-weight: bold;
}

.confirm .small {
    font-size: 0.9rem;
    font-weight: normal;
}

.confirm-buttons {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.strip {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    min-height: 1.8rem;
    padding: 0.15rem 0.8rem;
    text-align: center;
    border-radius: 2em;
    background: rgba(0, 0, 0, 0.75);
    font-size: 0.8rem;
}

.strip:has(.winners:empty):has(.btn[hidden]) {
    visibility: hidden;
}

.strip .btn {
    padding: 0.1em 0.7em;
}

/* Duchy Tech Services badge, as on LAN_Check and WAN_Check */
.dts-foot {
    display: flex;
    justify-content: center;
    padding: 2.5rem 1rem 3.5rem;
}

.dts {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.35rem 0.9rem 0.45rem;
    border-radius: 1rem;
    background: #000000;
    color: #8b96a5;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
}

.dts-tb {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
}

.dts-box {
    display: flex;
    padding: 0.4rem 0.8rem;
    border: 0.06rem solid #2a3340;
    border-radius: 0.9rem;
    transition: border-color 0.15s;
}

.dts:hover .dts-box,
.dts:focus-visible .dts-box {
    border-color: #fffd0e66;
}

.dts-name {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.dts-name svg {
    flex: none;
    width: 1.92rem;
    height: 2rem;
}

.dts-name b {
    color: #fffd0e;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.dts-web {
    color: #2f7fdb;
    font-size: 1.05rem;
    line-height: 1.1;
    white-space: nowrap;
}

.wheel-box {
    flex: none;
    position: relative;
    margin-top: calc(var(--wheel) * 0.04);   /* room for the pointer, which stands proud of the wheel */
    transition: transform 0.6s ease, width 0.5s ease, height 0.5s ease, margin 0.5s ease;
    width: var(--wheel);
    height: var(--wheel);
}

/* Portrait: once the pasty result shows above it, the wheel shrinks to
   share the screen with it. */
@media (orientation: portrait) {
    .stage.has-result {
        --wheel: min(95vw, calc((100dvh - var(--bar-h) - 20.5rem) / 1.04));
    }
}

/* While it spins the top bar is away, so the wheel moves up into that
   space and zooms in. It settles back as the result arrives. */
.stage.spinning .wheel-box {
    transform: translateY(calc(var(--bar-h) * -0.5)) scale(var(--zoom));
}

@media (prefers-reduced-motion: reduce) {
    .wheel-box {
        transition: none;
    }

    .stage.spinning .wheel-box {
        transform: none;
    }
}

.wheel {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    font-weight: 600;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.wheel-box::before {
    content: "";
    position: absolute;
    inset: 1%;
    border-radius: 50%;
    box-shadow: 0 1.2rem 2rem rgba(0, 0, 0, 0.75), 0 0 0 0.15rem #000000;
}

/* Fixed light and shade over the turning wheel, so it reads as a domed disc */
.gloss {
    position: absolute;
    inset: 1%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 42%),
        radial-gradient(circle, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.4) 96%);
    box-shadow: inset 0 0 0.6rem rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.pointer {
    position: absolute;
    top: -4%;
    left: 45.5%;
    width: 9%;
    height: 14.4%;
    transform-origin: 50% 19%;
    filter: drop-shadow(0.15rem 0.3rem 0.25rem rgba(0, 0, 0, 0.8));
    pointer-events: none;
}

.spin {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18%;
    height: 18%;
    transform: translate(-50%, -50%);
    border: 0.2em solid var(--yellow);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #4a4a4a, #000000 65%);
    box-shadow: 0 0.3rem 0.6rem rgba(0, 0, 0, 0.8), inset 0 -0.2rem 0.4rem rgba(0, 0, 0, 0.9);
    color: var(--yellow);
    font: inherit;
    font-size: calc(var(--wheel) * 0.04);
    font-weight: bolder;
    cursor: pointer;
}

.burst {
    position: fixed;
    inset: 0;
    z-index: 3;
    overflow: hidden;
    pointer-events: none;
}

.pasty {
    position: absolute;
    z-index: 3;
    width: 9vmin;
    height: 6.3vmin;
    background: url("pasty.svg") center / contain no-repeat;
    opacity: 0;
    pointer-events: none;
}

@media (orientation: landscape) {
    :root {
        --zoom: 1.14;
        --title-w: min(60vw, 36rem);
        --wheel: min(44vw, calc((100dvh - var(--bar-h) - 5.5rem) / 1.04));
    }

    /* Title centred on the screen, menu at the right */
    .bar-inner {
        grid-template-columns: 3rem 1fr 3rem;
    }

    .title {
        grid-column: 2;
    }

    /* The pasty opens out beside the wheel, sliding it across */
    .stage {
        flex-direction: row;
    }


    .win {
        max-width: 0;
        max-height: none;
    }

    .stage.has-result .win {
        max-width: 44vw;
        max-height: none;
    }

    .cut {
        width: min(38vw, 30rem);
        max-width: none;
        height: auto;
        max-height: 62dvh;
    }

    .on-pasty {
        max-width: min(38vw, 30rem);
    }

    .result {
        font-size: min(clamp(1.6rem, 5.5vw, 3.8rem), calc(min(36vw, 28rem) / (var(--chars, 10) * 0.62)));
    }
}

/* Short and wide (a phone on its side) */
@media (orientation: landscape) and (max-height: 31rem) {
    :root {
        --title-w: min(50vw, 20rem);
        --wheel: min(44vw, calc((100dvh - var(--bar-h) - 3.4rem) / 1.04));
    }

    .first {
        gap: 0.2rem;
        padding-top: calc(var(--bar-h) + 0.3rem);
        padding-bottom: 0.3rem;
    }
}

/* ---------- shop page ---------- */

.shop-page {
    min-height: 100dvh;
    padding-top: var(--bar-h);
}

/* The pasty photo, pinned behind the page. Landscape screens get the photo
   as taken; portrait screens get the one in pics/portrait. */
.shop-page::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: #000000 var(--photo) center / cover no-repeat;
}

@media (orientation: portrait) {
    .shop-page::before {
        background-image: var(--photo-portrait);
    }
}

.shop {
    display: grid;
    gap: 1rem;
    max-width: 75rem;
    margin: 0 auto;
    padding: 1rem;
}

.card {
    padding: 1rem 1.2rem;
    border: 0.12rem solid var(--yellow);
    border-radius: 1rem;
    background: var(--panel);
}

.card h2 {
    margin: 1.2rem 0 0.4rem;
    color: var(--yellow);
    font-size: 1.1rem;
}

.card h2:first-child {
    margin-top: 0;
}

.card .btn {
    margin: 0.6rem 0.4rem 0 0;
}

.card .back {
    margin: 0;
    font-size: 1.15rem;
    box-shadow: 0 0.3rem 0.6rem rgba(0, 0, 0, 0.7);
}

.shop-name {
    margin: 0.6rem 0 0.2rem;
    color: var(--yellow);
    font-size: 2.2rem;
}

.address {
    margin: 0;
    font-size: 1.1rem;
}

.hours {
    margin: 0;
    padding: 0;
    list-style: none;
}

.small {
    font-size: 0.8rem;
    opacity: 0.75;
}

.note {
    font-style: italic;
}

.map-link {
    display: block;
    width: min(100%, 22rem);
    margin-top: 1rem;
    color: var(--text);
    text-align: center;
    text-decoration: none;
}

.map {
    display: block;
    width: 100%;
    border: 0.1rem solid #555555;
    border-radius: 0.8rem;
    background: #06131f;
}

.map-land {
    fill: #2a2a2a;
    stroke: var(--yellow);
    stroke-width: 0.6;
    stroke-linejoin: round;
}

.map-pasty {
    filter: drop-shadow(0 0 0.06rem #000000);
}

.branches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.3rem 0 0.8rem;
}

.branch {
    padding: 0.35em 0.8em;
    border: 0.1em solid var(--yellow);
    border-radius: 2em;
    background: #000000;
    color: var(--yellow);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

/* A supermarket's counters, folded under one button */
.store {
    padding: 0.35em 0.8em;
    border: 0.1em dashed var(--yellow);
    border-radius: 2em;
    background: #000000;
    color: var(--yellow);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
}

.store::after {
    content: " \25B8";
}

.store[aria-expanded="true"] {
    background: #2a2a00;
}

.store[aria-expanded="true"]::after {
    content: " \25BE";
}

.store-list {
    align-items: center;
    padding: 0.5rem 0.6rem;
    border-left: 0.2rem solid var(--yellow);
    background: rgba(255, 255, 255, 0.05);
}

.store-title {
    font-size: 0.85rem;
    font-weight: bold;
}

.branch.stockist {
    border-color: #6b6a2a;
    color: var(--text);
}

.branch[aria-pressed="true"] {
    background: var(--yellow);
    color: #000000;
    font-weight: bold;
}

.branch-details .branch-name {
    margin-top: 0;
    color: #ffffff;
}

.map-you {
    fill: #ffffff;
    stroke: #000000;
    stroke-width: 0.6;
}

.distance {
    margin: 0.2rem 0;
    color: var(--yellow);
    font-weight: bold;
}

/* Customise pasty list: a full-screen page over the site */
.list-page {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #000000;
    color: var(--text);
}

.list-page form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
    max-width: 34rem;
    margin: 0 auto;
    padding: 1rem;
}

.list-page h2 {
    margin: 0;
    color: var(--yellow);
    font-size: 1.6rem;
}

.list-shops {
    flex: 1;
    display: grid;
    align-content: start;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.list-shop {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 0.1rem solid #333333;
    border-radius: 0.7rem;
    background: #111111;
    color: #8a8a8a;
    font: inherit;
    font-size: 1.1rem;
    text-align: left;
    cursor: pointer;
}

.list-heading {
    margin-top: 0.6rem;
    color: var(--yellow);
    font-weight: bold;
}

.stockist-row:not([aria-pressed]) {
    color: var(--text);
    font-size: 1rem;
}

.review-branch {
    margin-left: auto;
    color: var(--yellow);
}

.review-form select {
    width: 100%;
    padding: 0.5em 0.7em;
    border: 0.1rem solid #555555;
    border-radius: 0.5rem;
    background: #111111;
    color: var(--text);
    font: inherit;
}

.list-shop:not([aria-pressed]) {
    color: #ffffff;
}

.list-shop[aria-pressed="true"] {
    border-color: var(--yellow);
    color: #ffffff;
    font-weight: bold;
}

.tick {
    display: grid;
    place-items: center;
    flex: none;
    width: 1.6rem;
    height: 1.6rem;
    border: 0.12rem solid #555555;
    border-radius: 0.4rem;
}

.list-shop[aria-pressed="true"] .tick {
    border-color: var(--yellow);
    background: var(--yellow);
}

.list-shop[aria-pressed="true"] .tick::after {
    content: "";
    width: 0.45rem;
    height: 0.8rem;
    margin-top: -0.15rem;
    border: solid #000000;
    border-width: 0 0.2rem 0.2rem 0;
    transform: rotate(45deg);
}

.list-note {
    min-height: 1.2em;
    margin: 0;
    color: #ff8080;
}

.list-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
}

.where input {
    width: min(18rem, 70vw);
    margin: 0.6rem 0 0.2rem;
    padding: 0.5em 0.7em;
    border: 0.1rem solid #555555;
    border-radius: 0.5rem;
    background: #111111;
    color: var(--text);
    font: inherit;
    font-size: 1.1rem;
}

.where input:focus {
    border-color: var(--yellow);
    outline: none;
}

.where-error {
    min-height: 1.2em;
    color: #ff8080;
}

.map-pin {
    fill: var(--yellow);
}

.map-ring {
    fill: none;
    stroke: var(--yellow);
    stroke-width: 0.8;
    opacity: 0.6;
}

.map-label {
    fill: #ffffff;
    font-weight: bold;
    paint-order: stroke;
    stroke: #000000;
    stroke-width: 1.2;
}

.review,
.saying {
    margin: 0.8rem 0;
    padding: 0.6rem 0.9rem;
    border-left: 0.25rem solid var(--yellow);
    background: rgba(255, 255, 255, 0.06);
}

.review p,
.saying p {
    margin: 0.2rem 0;
}

.review-head {
    display: flex;
    gap: 0.8rem;
    font-size: 0.85rem;
    opacity: 0.85;
}

.score {
    color: var(--yellow);
    font-weight: bold;
}

.saying p {
    font-size: 1.3rem;
    font-style: italic;
}

.saying footer {
    font-size: 0.85rem;
    opacity: 0.75;
}

@media (orientation: landscape) {
    .shop {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

/* ---------- submit a review ---------- */

/* Clear of the top bar when scrolled to */
.submit {
    scroll-margin-top: calc(var(--bar-h) + 1rem);
    scroll-margin-bottom: 1rem;
}

/* The review section, picked from the menu: glows yellow */
.card.picked {
    box-shadow: 0 0 0 0.15rem var(--yellow), 0 0 1.6rem rgba(251, 245, 8, 0.45);
    animation: picked 0.6s ease 2;
}

@keyframes picked {
    50% {
        box-shadow: 0 0 0 0.3rem var(--yellow), 0 0 2.6rem rgba(251, 245, 8, 0.7);
    }
}

.review-form {
    display: grid;
    gap: 0.7rem;
    margin-top: 0.9rem;
}

.review-form label {
    display: grid;
    gap: 0.25rem;
    font-size: 0.9rem;
}

.review-form input,
.review-form textarea {
    width: 100%;
    padding: 0.5em 0.7em;
    border: 0.1rem solid #555555;
    border-radius: 0.5rem;
    background: #111111;
    color: var(--text);
    font: inherit;
}

.review-form input[type="number"] {
    width: 6em;
}

.review-form input:focus,
.review-form textarea:focus {
    border-color: var(--yellow);
    outline: none;
}

.review-form .btn {
    justify-self: start;
    margin: 0;
}

/* ---------- wheel names: grow under the pointer ---------- */

.label {
    transition: font-size 0.14s ease-out;
}

.label.at-top {
    font-weight: 900;
}
