/* Melly Coffee Co. — landing page
   Mobile-first: base styles target 320–430px, enhanced at 820px and 1200px. */

:root {
    --paper: #f6f1e8;
    --ink: #2a1d16;
    --ink-soft: #6a584c;
    --rule: rgba(42, 29, 22, 0.16);
    --accent: #96481f;
    --night: #1c1410;
    --cream: #f8f2e7;
    --plate: #d9d2c3; /* shown behind photos while they load */

    --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --sans: "Jost", "Avenir Next", "Century Gothic", "Segoe UI", system-ui, sans-serif;

    --gutter: clamp(1.25rem, 6vw, 2.5rem);
    --space-block: clamp(3.5rem, 12vw, 8.5rem);
    --measure: 69rem;
    /* Near-square corners echo the thin rectangular frame of the logo */
    --radius: 0.25rem;

    --text-label: 0.75rem;
    --text-small: 0.9375rem;
    --text-body: 1.0625rem;
    --text-lead: clamp(1.25rem, 0.95rem + 1.35vw, 2.125rem);
    --text-display: clamp(1.875rem, 1.2rem + 3.6vw, 4rem);

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: var(--text-body);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p,
ul,
figure,
address {
    margin: 0;
    padding: 0;
    font: inherit;
}

ul {
    list-style: none;
}

img,
svg {
    display: block;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* Skip-link target: focus moves there, but a ring around the whole page would be noise */
main:focus {
    outline: none;
}

.skip-link {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 0.5rem);
    left: 0.5rem;
    z-index: 10;
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 1.25rem;
    border-radius: var(--radius);
    background: var(--cream);
    color: var(--ink);
    font-size: var(--text-small);
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

/* ---------- Top bar (sits over the hero photo) ---------- */

.topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 0.75rem) calc(max(var(--gutter), env(safe-area-inset-right)) - 0.75rem) 0 max(var(--gutter), env(safe-area-inset-left));
    color: #fff;
    font-size: var(--text-label);
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.lang {
    display: flex;
    align-items: center;
}

.lang__btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.25s var(--ease);
}

.lang__btn[aria-pressed="true"] {
    opacity: 1;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.45em;
}

.lang__sep {
    opacity: 0.5;
}

/* ---------- Hero ---------- */

.hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 100vh;
    min-height: 100svh;
    /* Reserves the top bar's space, so on short screens the hero grows instead of sliding the logo under it */
    padding-top: calc(env(safe-area-inset-top) + 4.5rem);
    overflow: hidden;
    background: var(--night);
    color: #fff;
}

.hero__media,
.hero__media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.hero__media img {
    object-fit: cover;
}

/* Bottom-up scrim keeps logo, tagline and CTA at AA contrast. The top scrim does the same for the top bar: its length
   follows the bar, not the hero height, so it holds on short screens and with whatever photo replaces this one. */
.hero__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to top, rgba(28, 20, 16, 0.94) 0%, rgba(28, 20, 16, 0.82) 34%, rgba(28, 20, 16, 0.42) 56%, rgba(28, 20, 16, 0) 80%),
        linear-gradient(to bottom, rgba(28, 20, 16, 0.7) 0, rgba(28, 20, 16, 0.62) calc(env(safe-area-inset-top) + 4.5rem), rgba(28, 20, 16, 0) calc(env(safe-area-inset-top) + 11rem));
}

.hero__content {
    position: relative;
    width: 100%;
    max-width: calc(var(--measure) + 2 * var(--gutter));
    margin-inline: auto;
    padding: 0 max(var(--gutter), env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + clamp(2rem, 7vh, 4rem)) max(var(--gutter), env(safe-area-inset-left));
}

.hero__logo img {
    width: clamp(10rem, 46vw, 13rem);
}

.hero__tagline {
    max-width: 16ch;
    margin: 1.5rem 0 2rem;
    font-family: var(--serif);
    font-size: var(--text-display);
    font-weight: 300;
    line-height: 1.12;
    letter-spacing: -0.015em;
    text-wrap: balance;
}

/* ---------- Buttons ---------- */

.btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 22rem;
    min-height: 3.5rem;
    padding: 0 1.25rem 0 1.5rem;
    border: 1px solid transparent; /* becomes the button's outline in forced-colors mode */
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    transition: background-color 0.3s var(--ease), color 0.3s var(--ease), transform 0.2s var(--ease);
}

.btn--light {
    background: var(--cream);
    color: var(--ink);
}

/* The default ring uses currentColor, i.e. the label colour, which vanishes against the dark photo behind the button */
.btn--light:focus-visible {
    outline-color: var(--cream);
}

.btn svg {
    flex: none;
}

.btn__icon {
    margin-left: auto;
    transition: transform 0.3s var(--ease);
}

.btn:active {
    transform: scale(0.97);
}

@media (hover: hover) {
    .btn--light:hover {
        background: #fff;
    }

    .btn:hover .btn__icon {
        transform: translateX(4px);
    }
}

/* ---------- Editorial blocks ---------- */

.block,
.plate,
.footer {
    max-width: var(--measure);
    margin-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

.block {
    padding-block: var(--space-block);
    border-top: 1px solid var(--rule);
}

.hero + .block {
    border-top: 0;
}

.eyebrow {
    margin-bottom: 1.75rem;
    color: var(--ink-soft);
    font-size: var(--text-label);
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.lead {
    font-family: var(--serif);
    font-size: var(--text-lead);
    font-weight: 300;
    line-height: 1.45;
    letter-spacing: -0.01em;
    text-wrap: pretty;
}

/* ---------- Instagram ---------- */

.insta .link {
    margin-top: 0.75rem;
}

.insta__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-top: 1.75rem;
}

.insta__grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--plate);
}

.plate {
    margin-bottom: var(--space-block);
    background: var(--plate);
}

.plate img {
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
}

/* ---------- Locations ---------- */

.place {
    position: relative;
    padding-block: 1.5rem 0.75rem;
    border-top: 1px solid var(--rule);
}

.place:first-child {
    padding-top: 0;
    border-top: 0;
}

.place:last-child {
    padding-bottom: 0;
}

.place__name {
    font-family: var(--serif);
    font-size: clamp(1.625rem, 1.3rem + 1.4vw, 2.25rem);
    font-weight: 300;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.place__info {
    margin-top: 0.5rem;
}

.place__address {
    max-width: 30ch;
    color: var(--ink-soft);
    font-size: var(--text-small);
    font-style: normal;
    line-height: 1.6;
}

.place__hours {
    margin-top: 0.375rem;
    color: var(--ink-soft);
    font-size: var(--text-small);
    line-height: 1.6;
}

.place__hours time {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    font-size: var(--text-label);
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    transition: color 0.25s var(--ease);
}

.link svg {
    flex: none;
    transition: transform 0.3s var(--ease);
}

.place .link {
    margin-top: 0.5rem;
}

/* The directions link covers its whole row, so the entire branch is one comfortable tap target */
.place .link::after {
    content: "";
    position: absolute;
    inset: 0;
}

.place .link:active svg {
    transform: translate(2px, -2px);
}

.link--handle {
    font-size: var(--text-small);
    letter-spacing: 0.04em;
    text-transform: none;
}

.link--quiet {
    gap: 0.625rem;
    color: var(--ink);
    font-size: var(--text-small);
    font-weight: 400;
    letter-spacing: 0.02em;
    text-transform: none;
}

@media (hover: hover) {
    .link:hover {
        color: var(--ink);
    }

    .link--quiet:hover {
        color: var(--accent);
    }

    .place .link:hover svg {
        transform: translate(2px, -2px);
    }
}

/* ---------- Footer ---------- */

.footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding-block: 3rem calc(env(safe-area-inset-bottom) + 2.5rem);
    border-top: 1px solid var(--rule);
    text-align: center;
}

.footer__logo {
    width: 6.625rem;
}

.footer__links {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer__note {
    max-width: 34ch;
    color: var(--ink-soft);
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
    text-wrap: balance;
}

.footer__legal {
    color: var(--ink-soft);
    font-size: 0.8125rem;
    letter-spacing: 0.02em;
}

/* ---------- Motion (only when welcome) ---------- */

@media screen and (prefers-reduced-motion: no-preference) {
    .hero__media img {
        animation: hero-settle 1.8s var(--ease) both;
    }

    .hero__content > * {
        animation: rise 0.9s var(--ease) both;
    }

    .hero__content > :nth-child(1) { animation-delay: 0.25s; }
    .hero__content > :nth-child(2) { animation-delay: 0.4s; }
    .hero__content > :nth-child(3) { animation-delay: 0.55s; }

    /* landing.js adds .js only after it has marked what is already on screen, so nothing is hidden without it */
    .js .reveal {
        opacity: 0;
        transform: translateY(1.25rem);
        transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
    }

    .js .reveal.is-visible {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .btn,
    .btn__icon,
    .link,
    .link svg,
    .lang__btn {
        transition: none;
    }
}

@keyframes hero-settle {
    from {
        opacity: 0;
        transform: scale(1.06);
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
}

/* ---------- Tablet and up ---------- */

@media (min-width: 820px) {
    :root {
        --text-label: 0.8125rem;
        --text-small: 1rem;
    }

    .topbar {
        padding-top: calc(env(safe-area-inset-top) + 1.5rem);
    }

    .hero__logo img {
        width: 17rem;
    }

    .btn {
        display: inline-flex;
        width: auto;
        min-width: 17rem; /* = hero logo width */
        min-height: 3.75rem;
        font-size: 0.875rem;
    }

    /* Label column + content column, like a magazine spread */
    .block {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr);
        column-gap: 3rem;
        align-items: baseline;
    }

    .eyebrow {
        margin: 0;
    }

    .insta__grid {
        grid-column: 1 / -1;
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
        margin-top: 3rem;
    }

    .plate img {
        aspect-ratio: 16 / 9;
    }

    .place {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
        column-gap: 2rem;
        align-items: baseline;
        padding-block: 1.75rem 1rem;
    }

    .place:first-child {
        padding-top: 0;
    }

    .place:last-child {
        padding-bottom: 0;
    }

    .place__info {
        margin-top: 0;
    }

    .place .link {
        grid-column: 2;
        justify-self: start;
    }

    .footer {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        text-align: left;
    }

    .footer__links {
        flex-direction: row;
        gap: 2rem;
    }

    /* the note sits on its own line under the logo / Instagram / copyright row */
    .footer__note {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
        max-width: none;
        text-align: center;
    }

    .footer__legal {
        justify-self: end;
        text-align: right;
    }

    .footer__legal [data-i18n] {
        display: inline-block;
    }
}

/* From here the measure is narrower than the window, so content is centred (74rem = measure + 2 gutters) */
@media (min-width: 74rem) {
    .topbar {
        padding-inline: calc((100% - var(--measure)) / 2) calc((100% - var(--measure)) / 2 - 0.75rem);
    }

    .block,
    .plate,
    .footer {
        margin-inline: auto;
    }
}

@media (min-width: 1200px) {
    .hero__logo img {
        width: 19rem;
    }

    .btn {
        min-width: 19rem;
    }

    .place {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 11rem;
        padding-block: 1.75rem;
    }

    .place .link {
        grid-column: 3;
        justify-self: end;
    }

    .place .link {
        margin-top: 0;
    }
}

/* ---------- Short screens (phones held sideways) ---------- */

@media (max-height: 520px) {
    .hero__logo img {
        width: 13rem;
    }

    .hero .btn {
        min-width: 13rem;
    }

    .hero__tagline {
        max-width: none;
        margin: 1rem 0 1.25rem;
        font-size: 1.75rem;
    }
}
