/*
 * Employee Meal Discount PWA. Mobile first, portrait. Screens follow the Figma design.
 * Client brand colours: Wasabi green #CCD400 and Seaweed green #003F23.
 * No inline styles are used anywhere in the markup (the content security policy forbids them).
 */
/* The client's Wasabi font. It has four weights (300, 400, 500, 700); anything heavier than 500 uses Bold. */
@font-face { font-family: "Wasabi"; font-weight: 300; font-style: normal; font-display: swap; src: url("/fonts/Wasabi-Light.otf") format("opentype"); }
@font-face { font-family: "Wasabi"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/Wasabi-Regular.otf") format("opentype"); }
@font-face { font-family: "Wasabi"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/Wasabi-Medium.otf") format("opentype"); }
@font-face { font-family: "Wasabi"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/Wasabi-Bold.otf") format("opentype"); }

:root {
    --seaweed: #003F23;
    --seaweed-deep: #002A17;
    --wasabi: #CCD400;
    --ink: #10281c;
    --muted: #6b7d71;
    --paper: #f5f6f0;
    --card: #ffffff;
    --line: #dde4d6;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: "Wasabi", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    color: var(--ink);
    background: var(--paper);
}

h1, h2, p { margin: 0; }

.icon {
    flex: none;
    width: 1.25em;
    height: 1.25em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---- header ---- */
/* The logo is dark green and Wasabi green, drawn for a light background. */
.app-header {
    background: var(--seaweed);
    /* In landscape a notch sits at the side, so the sides keep clear of the safe area too. */
    padding: env(safe-area-inset-top) max(1.3rem, env(safe-area-inset-right)) 0 max(1.3rem, env(safe-area-inset-left));
}

.app-header-inner {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    max-width: 30rem;
    margin: 0 auto;
    min-height: 4.5rem;
    padding: 10px 20px;
}

.header-back {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    margin-left: -0.4rem;
    color: var(--wasabi);
    border-radius: 50%;
}

.header-back .icon { width: 1.4rem; height: 1.4rem; stroke-width: 2.2; }
.header-back:focus-visible { outline: 3px solid var(--wasabi); outline-offset: 2px; }

/* The logo is dark green and Wasabi green, drawn for a light background, so it sits on a small white rounded plate. */
.app-logo { display: block; height: 3rem; width: auto; padding: 0.25rem 0.45rem; background: #ffffff; border-radius: 0.5rem; }

/* ---- page ---- */
.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 30rem;
    margin: 0 auto;
    padding: 1.3rem max(1.3rem, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 1.5rem) max(1.3rem, env(safe-area-inset-left));
}

/* ---- profile ---- */
.profile {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.95rem 1.1rem;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 1px 4px rgba(16, 40, 28, 0.08);
}

.avatar {
    flex: none;
    display: grid;
    place-items: center;
    width: 3.3rem;
    height: 3.3rem;
    border-radius: 50%;
    background: var(--wasabi);
    color: var(--seaweed);
    font-weight: 700;
    font-size: 1rem;
}

.profile-text { min-width: 0; }
.profile-name { font-size: 1.02rem; font-weight: 700; line-height: 1.35; color: var(--seaweed); overflow-wrap: anywhere; }
.profile-role { font-size: 0.8rem; font-weight: 400; color: var(--muted); line-height: 1.4; }
.profile-meta { font-size: 0.7rem; color: var(--muted); line-height: 1.4; }

.section-label {
    margin: 1.4rem 0 0.7rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---- discount cards ---- */
.tier-card {
    padding: 1.1rem;
    margin-bottom: 0.6rem;
    border-radius: 20px;
}

.tier-card.tier-fifty { background: var(--wasabi); color: var(--seaweed); }
.tier-card.tier-hundred { background: var(--seaweed); color: var(--wasabi); }

.tier-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.tier-percent { white-space: nowrap; font-size: clamp(1.6rem, 8.6vw, 2.55rem); font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; }

.tier-once {
    flex: none;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    background: rgba(0, 63, 35, 0.14);
}

.tier-hundred .tier-once { background: rgba(204, 212, 0, 0.2); }

.tier-title { margin: 0.3rem 0 1rem; font-size: 0.8rem; font-weight: 500; }
.tier-hundred .tier-title { color: #c4cdb6; }

/* Shown instead of the discount cards while there is no code to give. */
.empty-state {
    margin-top: 0.8rem;
    padding: 1.6rem 1.4rem;
    text-align: center;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 1px 4px rgba(16, 40, 28, 0.08);
}

.empty-title { font-size: 1.1rem; font-weight: 700; line-height: 1.35; color: var(--seaweed); }
.empty-text { max-width: 19rem; margin: 0.45rem auto 0; font-size: 0.85rem; line-height: 1.55; color: var(--muted); }

.btn-generate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.95rem;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.tier-fifty .btn-generate { background: var(--seaweed); color: #ffffff; }
.tier-fifty .btn-generate .icon { color: var(--wasabi); }
.tier-hundred .btn-generate { background: var(--wasabi); color: var(--seaweed); }
.btn-generate .icon { width: 1.1rem; height: 1.1rem; }
.btn-generate:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.btn-generate:active { transform: scale(0.99); }

.note {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin-top: 0.8rem;
    font-size: 0.72rem;
    color: var(--muted);
}

.note .icon { margin-top: 0.1rem; width: 1.1rem; height: 1.1rem; }

.signed-in {
    margin-top: auto;
    padding-top: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 0.68rem;
    color: var(--muted);
}

.signed-in-dot { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--wasabi); }

/* ---- code screen ---- */
.code-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* The column wrappers take no part in the layout on a narrow phone: everything stacks as before. A wide screen turns them into columns. */
.code-left,
.code-right,
.code-entry { display: contents; }

/* A plain circle with the offer in it, above the QR. */
.bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 9.9rem;
    aspect-ratio: 1;
    margin-top: 0.3rem;
    border-radius: 50%;
    background: var(--wasabi);
    color: var(--seaweed);
}

.tier-hundred .bubble { background: var(--seaweed); color: var(--wasabi); }

.bubble-small { font-size: 0.88rem; font-weight: 500; }
.bubble-percent { font-size: 2.9rem; font-weight: 700; line-height: 1.05; letter-spacing: -0.03em; }
.bubble-percent small { font-size: 1.45rem; font-weight: 700; letter-spacing: 0; }

.qr-card {
    margin: 1.1rem auto 0;
    padding: 1.3rem 1.3rem 0.85rem;
    width: 100%;
    max-width: 15.5rem;
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 2px 10px rgba(16, 40, 28, 0.1);
}

.qr svg { display: block; width: 100%; height: auto; }

.issued {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 0.6rem;
    font-size: 0.66rem;
    color: var(--muted);
}

.instruction { max-width: 15.7rem; margin-top: 1.2rem; font-size: 0.83rem; font-weight: 500; color: var(--seaweed); }

.code-number {
    margin: 0.4rem 0 1.5rem;
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.15;
    color: var(--seaweed);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    width: 100%;
    margin-top: auto;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: #e6e9de;
    font-size: 0.7rem;
    text-align: left;
    color: var(--muted);
}

.notice .icon { margin-top: 0.1rem; width: 1.2rem; height: 1.2rem; }

/*
 * Wide screens: a phone on its side, a tablet, a desktop window. A narrow phone (under 640px) keeps the stacked
 * design above. Home: a wider column, the two discounts side by side. Code screen: the
 * bubble and the QR on the left, the code in a white card with the notice under it on the right.
 */
@media (min-width: 640px) {
    .app-header-inner,
    .app-content { max-width: 64rem; }

    .app-content { padding-top: 1.75rem; padding-bottom: calc(env(safe-area-inset-bottom) + 2rem); }

    /* home */
    .profile { padding: 1.25rem 1.5rem; }
    .avatar { width: 3.5rem; height: 3.5rem; }
    .profile-name { font-size: 1.1rem; }

    .tier-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    .tier-card { margin-bottom: 0; padding: 1.75rem; }
    .tier-title { margin: 0.5rem 0 2.4rem; font-size: 0.9rem; }
    .btn-generate { min-height: 3.2rem; font-size: 0.95rem; }

    /* code screen */
    .code-screen { flex-direction: row; justify-content: center; align-items: center; gap: 5rem; }

    .code-left,
    .code-right { display: flex; flex-direction: column; align-items: center; }

    .code-left { gap: 1.25rem; }
    .bubble { width: 11rem; margin: 0; }
    .qr-card { width: 18rem; max-width: none; margin: 0; padding: 1.5rem 1.5rem 1rem; }

    .code-right { width: 25rem; gap: 1.5rem; }

    .code-entry {
        display: block;
        width: 100%;
        padding: 2rem 1.5rem;
        background: #ffffff;
        border-radius: 24px;
        box-shadow: 0 2px 10px rgba(16, 40, 28, 0.08);
        text-align: center;
    }

    .instruction { max-width: 16rem; margin: 0 auto; }
    .code-number { margin: 0.75rem 0 0; }
    .notice { margin-top: 0; }
}

/* A wide screen that is also short (a phone on its side): everything a little smaller so the code screen fits without scrolling. */
@media (min-width: 640px) and (max-height: 520px) {
    .app-header-inner { min-height: 3.3rem; }
    .app-logo { height: 2.5rem; }
    .app-content { padding-top: 0.6rem; padding-bottom: calc(env(safe-area-inset-bottom) + 0.6rem); }

    .section-label { margin-top: 0.9rem; }
    .tier-card { padding: 1.1rem; }
    .tier-title { margin-bottom: 1rem; }
    .signed-in { padding-top: 1rem; }

    .code-screen { gap: 2.5rem; }
    .code-left { gap: 0.6rem; }
    .bubble { width: 7rem; }
    .bubble-small { font-size: 0.62rem; }
    .bubble-percent { font-size: 1.9rem; }
    .bubble-percent small { font-size: 0.95rem; }
    .qr-card { width: 11rem; padding: 0.8rem 0.8rem 0.5rem; }
    .issued { margin-top: 0.4rem; font-size: 0.58rem; }

    .code-right { width: 19rem; gap: 0.8rem; }
    .code-entry { padding: 1.1rem 1rem; }
    .instruction { font-size: 0.75rem; }
    .code-number { margin-top: 0.4rem; font-size: 2.3rem; }
    .notice { padding: 0.6rem 0.8rem; font-size: 0.62rem; }
}

/* The shortest phones on their side (about 400px tall or less): one more step smaller. */
@media (min-width: 640px) and (max-height: 400px) {
    .app-content { padding-top: 0.45rem; padding-bottom: calc(env(safe-area-inset-bottom) + 0.45rem); }
    .code-left { gap: 0.45rem; }
    .bubble { width: 6.3rem; }
    .bubble-percent { font-size: 1.7rem; }
    .qr-card { width: 10rem; padding: 0.65rem 0.65rem 0.4rem; }
    .issued { margin-top: 0.3rem; }
}

/* ---- messages and development sign-in ---- */
.message-card {
    margin-top: 0.4rem;
    padding: 1.3rem;
    background: var(--card);
    border-radius: 18px;
    box-shadow: 0 1px 4px rgba(16, 40, 28, 0.08);
}

.message-card h1 { font-size: 1.2rem; font-weight: 700; color: var(--seaweed); margin-bottom: 0.4rem; }
.message-card p { font-size: 0.9rem; color: var(--muted); }

.dev-row { margin-top: 0.7rem; }

.dev-employee {
    display: block;
    width: 100%;
    padding: 0.9rem 1rem;
    text-align: left;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    font: inherit;
    cursor: pointer;
}

.dev-employee span { display: block; font-size: 0.82rem; color: var(--muted); }

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