/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --teal: #0f766e;
    --teal-shadow: rgba(15, 118, 110, .5);
    --gold-dark: #5d4a1f;
    --red: #b91c1c;
    --red-shadow: rgba(185, 28, 28, .5);
    --text: #0f172a;
    --btn-text: #fee2e2;
    --border: #e5e7eb;
    --input-bg: #f9fafb;
    --placeholder: #9ca3af;
    --yellow-shadow: rgba(161, 98, 7, .5);
}

html { font-family: system-ui, -apple-system, sans-serif; color: var(--text); }
body { min-height: 100vh; display: flex; flex-direction: column; background: #fff; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img { display: inline-block; vertical-align: middle; }

/* === Layout === */
main { flex: 1; }
.container { max-width: 72rem; margin: 0 auto; padding: 0 1.25rem; }

/* === Typography === */
h1 { font-size: 2.25rem; margin-top: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.875rem; }
.text-xl { font-size: 1.25rem; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .75rem;
    border: none; border-radius: .375rem; padding: .75rem; cursor: pointer;
    font: inherit; font-size: 1rem; color: var(--btn-text);
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-gold {
    background:
        radial-gradient(ellipse farthest-corner at right bottom, #FEDB37 0%, #FDB931 8%, #9f7928 30%, #8A6E2F 40%, transparent 80%),
        radial-gradient(ellipse farthest-corner at left top, #FFFFFF 0%, #FFFFAC 8%, #D1B464 25%, #5d4a1f 62.5%, #5d4a1f 100%);
    box-shadow: 0 10px 15px -3px var(--yellow-shadow);
}

.btn-teal {
    background: var(--teal);
    box-shadow: 0 10px 15px -3px var(--teal-shadow);
}

.btn-red {
    background: var(--red);
    box-shadow: 0 10px 15px -3px var(--red-shadow);
}

.btn-sm { padding: .5rem; }
.btn-outline { outline: 2px solid var(--teal); outline-offset: 2px; }
.btn-ghost { background: transparent; box-shadow: none; font-size: 1.75rem; }

/* === Forms / Inputs === */
input[type="text"], input[type="email"], input[type="password"], input[type="date"], select {
    display: block; width: 100%; padding: .5rem; font: inherit;
    border: 1px solid var(--border); border-radius: .375rem;
    background: var(--input-bg);
}
input::placeholder { color: var(--placeholder); }
label { display: block; }
label > span.label-text { display: block; margin-bottom: .5rem; }

.field-errors { color: var(--red); font-weight: 700; margin-top: .25rem; }
.field-errors li { margin-top: .125rem; }

.form-group { margin-bottom: 1.5rem; }

/* === Header === */
header {
    box-shadow: 0 4px 6px -1px rgba(0,0,0,.1);
    padding: 1.5rem 0;
}
header nav .header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 4rem;
}
.brand { display: flex; align-items: center; font-size: 1.5rem; font-weight: 700; color: var(--red); gap: .75rem; }
.brand img { width: 2rem; height: 2rem; }
.nav-links { display: flex; align-items: center; gap: .25rem; flex: 1; margin-left: 1.5rem; }
.nav-links a, .nav-links form, .nav-links button {
    padding: .75rem; display: flex; align-items: center; justify-content: center;
    white-space: nowrap;
}
.nav-links button { background: none; border: none; cursor: pointer; font: inherit; color: inherit; }
.nav-spacer { flex: 1; }
.lang-links { display: flex; gap: .5rem; }
.lang-links a { padding: .5rem .75rem; border-radius: .375rem; }
.lang-links a.active { background: var(--teal); color: var(--btn-text); }

/* Mobile menu toggle */
.mobile-toggle { display: none; background: none; border: none; cursor: pointer; padding: .5rem; font-size: 1.5rem; }

@media (max-width: 640px) {
    .mobile-toggle { display: block; }
    .nav-links { display: none; }
    .nav-links.open {
        display: flex; flex-direction: column; align-items: stretch;
        position: absolute; top: 100%; left: 0; right: 0; background: #fff;
        box-shadow: 0 4px 6px -1px rgba(0,0,0,.1); padding: .5rem; z-index: 10;
    }
    .nav-spacer { display: none; }
    header nav { position: relative; }
}

/* === Footer === */
footer {
    border-top: 1px solid var(--border);
    margin-top: 2.5rem; padding: .5rem 0; height: 2.5rem;
    display: flex; align-items: center;
}
footer a { padding: .5rem; border-radius: .375rem; }

/* === Responsive Grid === */
.rgrid {
    display: grid; grid-template-columns: 1fr; gap: 1.25rem;
}
@media (min-width: 640px)  { .rgrid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px)  { .rgrid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .rgrid { grid-template-columns: repeat(4, 1fr); } }

/* === Event Cards === */
.event-card {
    display: block; border-radius: .375rem; padding: 1.25rem;
    background: var(--teal); color: var(--btn-text);
    box-shadow: 0 10px 15px -3px var(--teal-shadow);
}
.event-card:hover { opacity: .9; }
.event-card h3 { font-size: 1.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: .5rem; }
.event-card .meta { display: flex; align-items: center; gap: .5rem; margin-top: .25rem; }
/* What the user is in the event: organizer, tied participant, or both. */
.event-card .roles { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.event-card .role {
    font-size: .8rem; padding: .15rem .5rem; border-radius: 1rem;
    background: rgba(255, 255, 255, .18); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.role-filter { display: flex; gap: .5rem; flex-wrap: wrap; }

/* === Rule Cards === */
.rule-cards {
    display: grid; grid-template-columns: 1fr; gap: 1.25rem;
}
@media (min-width: 640px) { .rule-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .rule-cards { grid-template-columns: repeat(3, 1fr); } }
.rule-cards form { display: contents; }
.rule-card {
    display: flex; flex-direction: column; gap: .5rem;
    border-radius: .375rem; padding: 1.25rem;
    background: var(--teal); color: var(--btn-text);
    box-shadow: 0 10px 15px -3px var(--teal-shadow);
    cursor: pointer; text-align: left; width: 100%;
    border: none; font: inherit;
}
.rule-card:hover { opacity: .9; }
.rule-card strong { font-size: 1.25rem; }
.rule-card span { font-size: .875rem; opacity: .85; }

/* === Home Page: the answers the visitor can open, above everything else === */
.home-answers { margin-top: 2rem; }
.home-answers h2 {
    font-family: 'Fraunces', serif; font-optical-sizing: auto;
    font-size: 1.75rem; margin-bottom: 1rem;
}
.answer-list { display: flex; flex-direction: column; gap: .75rem; }
.answer-line {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
    border: 1px solid var(--border); border-radius: .375rem; padding: 1rem 1.25rem;
    background: var(--input-bg); font-size: 1.125rem;
}
.answer-line:hover { border-color: var(--teal); }
.answer-line .answer-event { font-weight: 700; }
.answer-line .meta { display: flex; align-items: center; gap: .5rem; color: var(--muted, #6b6b6b); }
.answer-line .answer-participant { flex: 1; }

/* === Home Page === */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(1.5rem); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes gift-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-.75rem); }
}

.hero {
    display: flex; flex-direction: column; align-items: center;
    text-align: center; padding: 5rem 0 3rem;
}
.hero-gift {
    font-size: 5rem;
    animation: fade-up .6s ease both, gift-float 3s ease-in-out .8s infinite;
}
.hero-title {
    font-family: 'Fraunces', serif; font-optical-sizing: auto;
    font-size: 5rem; font-weight: 800;
    background: linear-gradient(135deg, var(--red) 30%, #d97706);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: .5rem 0 0; line-height: 1.1; padding-bottom: .15em;
    animation: fade-up .6s ease .1s both;
}
.hero-tagline {
    max-width: 36rem; font-size: 1.25rem; line-height: 1.7;
    color: var(--placeholder); margin-top: 1.5rem;
    animation: fade-up .6s ease .2s both;
}
.hero-cta {
    margin-top: 2.5rem; padding: 1rem 2.5rem; font-size: 1.25rem;
    animation: fade-up .6s ease .3s both;
}
@media (max-width: 640px) {
    .hero { padding: 3rem 0 2rem; }
    .hero-gift { font-size: 3.5rem; }
    .hero-title { font-size: 3rem; }
}

.home-how {
    margin-top: 2rem; text-align: center;
}
.home-how h2 {
    font-family: 'Fraunces', serif; font-optical-sizing: auto;
    font-size: 2.25rem; margin-bottom: 2.5rem;
    animation: fade-up .6s ease .4s both;
}
.home-steps {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.25rem;
}
.home-step {
    display: flex; flex-direction: column; align-items: center; gap: .75rem;
    padding: 2rem 1rem; border-radius: .75rem;
    border: 1px solid var(--border); background: #fff;
    animation: fade-up .5s ease both;
}
.home-step:nth-child(1) { animation-delay: .45s; }
.home-step:nth-child(2) { animation-delay: .55s; }
.home-step:nth-child(3) { animation-delay: .65s; }
.home-step:nth-child(4) { animation-delay: .75s; }
.home-step:nth-child(5) { animation-delay: .85s; }
.home-step-icon { font-size: 2rem; }
.home-step p { font-size: .95rem; line-height: 1.5; }
@media (max-width: 768px) {
    .home-steps { grid-template-columns: 1fr; max-width: 24rem; margin: 0 auto; }
}

.home-features {
    margin-top: 4rem; padding: 2rem; border-radius: .75rem;
    background: linear-gradient(135deg, #fefce8, #fef3c7);
    border-left: 4px solid #d97706;
    animation: fade-up .6s ease .95s both;
}
.home-features p {
    font-size: 1.1rem; line-height: 1.8; color: var(--gold-dark);
}

/* === Section spacing === */
.section { margin-top: 3rem; }
.section-header { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; }
.section-header h2 { flex: 1; }
.spaced > * + * { margin-top: 1.5rem; }

/* === Participants === */
.participant-row {
    display: flex; align-items: center; gap: 1.25rem;
    border: 1px solid var(--border); border-radius: .375rem; padding: 1.25rem;
    font-size: 1.25rem;
}
.participant-row.highlight { outline: 2px solid var(--red); }
.participant-name { flex: 1; }
.person-label { flex: 1; display: inline-flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.person-label .participant-name { flex: none; }
/* The organizer's own word for which of two same-named people this is. */
.person-note { font-size: .85em; font-style: italic; color: var(--muted, #6b6b6b); }
/* Whom the person is tied to, and for the tied user, whose list they are on. */
.person-tie, .person-organizer { font-size: .85em; color: var(--teal); }
/* Tied to the reader: spotted at once, in their own list too. */
.person-tie-me {
    background: var(--teal); color: var(--btn-text);
    border-radius: 1rem; padding: .1rem .6rem; font-size: .75em; font-style: normal;
}
.person-tie-row { margin-top: 1rem; }
.checkbox-line { display: flex; align-items: center; gap: .75rem; cursor: pointer; }
.checkbox-line input[type="checkbox"] { width: auto; accent-color: var(--teal); }
/* What the person has been to lately: a couple of names and a count, on one line that gives way. */
.person-events {
    font-size: .85em; color: var(--muted, #6b6b6b);
    max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
a.person-label:hover .participant-name { text-decoration: underline; }
.btn .person-note, .btn .person-events, .btn .meta { font-size: .85em; opacity: .85; color: inherit; }

/* The people a typed name could already mean, and the way to insist on someone new. */
.known-people { margin-top: 1.5rem; }
.known-people-choices {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: .75rem;
}
.known-person .btn { width: 100%; justify-content: flex-start; flex-wrap: wrap; text-align: left; }

/* === Rules === */
.rule-row {
    display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
}
.rule-row.impossible { color: #a16207; }
.rule-group-btn {
    background: var(--teal); color: var(--btn-text);
    border: none; border-radius: .375rem; padding: .75rem;
    cursor: pointer; font: inherit;
}
.add-rule-row {
    display: flex; align-items: center; gap: .75rem; margin-top: .75rem;
}
.add-rule-row span { color: var(--placeholder); }

/* === Draws === */
.draw-list li {
    display: flex; align-items: center; gap: .75rem;
    margin-bottom: .75rem; font-size: 1.25rem;
}

/* === Pager === */
.pager {
    display: flex; align-items: center; gap: 1.25rem;
    margin-top: 1.25rem;
}
.pager .page-info { font-size: 1.25rem; }

/* === Controls bar === */
.controls {
    display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: center;
    margin-top: 3rem;
}
.controls .spacer { flex: 1; }

/* === Auth forms === */
.auth-page { margin-top: 2rem; display: flex; flex-direction: column; align-items: center; }
.auth-form { display: flex; flex-direction: column; width: 100%; max-width: 32rem; gap: 2rem; }

/* === Profile === */
.danger-box {
    border: 1px solid var(--red); border-radius: .375rem;
    box-shadow: 0 1px 3px var(--red-shadow);
    padding: 1.25rem; max-width: 32rem;
}
.danger-box h2 { font-size: 1.5rem; margin-bottom: 1rem; }

/* === Share page === */
.confirm-box { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.share-link-box {
    border: 1px solid var(--border); border-radius: .375rem; padding: .75rem;
    word-break: break-all; background: var(--input-bg);
}

/* === Share links (admin post-draw) === */
.share-description {
    color: var(--placeholder); margin-bottom: 1rem;
}
.form-group .share-description { display: block; margin-top: .75rem; }
.share-link-row {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    border: 1px solid var(--border); border-radius: .375rem; padding: 1rem;
    background: var(--input-bg); word-break: break-all;
}
.share-link-row span { flex: 1; }
.personal-links { display: flex; flex-direction: column; gap: .75rem; }
.personal-link-row {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    border: 1px solid var(--border); border-radius: .375rem; padding: 1rem;
    background: var(--input-bg); word-break: break-all;
}
.personal-link-name { min-width: 8rem; }
/* A participant who has seen the answer, through a link that is dead now or through their account. */
.link-used {
    color: var(--muted, #6b6b6b);
    font-size: 0.85em; font-style: italic;
}
.share-link-url { flex: 1; word-break: break-all; }
.share-link-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.hidden { display: none; }

/* === Discover landing === */
.discover-landing {
    text-align: center; margin-top: 6rem;
}
.discover-landing h1 { font-size: 2.5rem; }
.discover-landing p { font-size: 1.5rem; margin-top: 1.5rem; }
.discover-landing .btn { margin-top: 2.5rem; display: inline-flex; }
.discover-landing-actions {
    display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap;
    margin-top: 2.5rem;
}
.invite-names {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 1rem; max-width: 48rem; margin: 2.5rem auto 0;
}
.invite-name {
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; border-radius: .5rem; font-size: 1.125rem; font-weight: 600;
    border: 2px solid var(--border); background: #fff;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}
.invite-name:hover {
    border-color: var(--teal); transform: translateY(-2px);
    box-shadow: 0 6px 16px -4px var(--teal-shadow);
}
.invite-name.claimed {
    font-weight: 400; color: var(--placeholder); border-style: dashed; background: transparent;
}
/* The viewer's own name, tied to their account: the one they came for. */
.invite-name.mine { border-color: var(--teal); box-shadow: 0 6px 16px -4px var(--teal-shadow); color: var(--teal); }
.discover-landing h2 { font-size: 1.75rem; margin-top: 1.5rem; }

/* === Gift reveal === */
.gift-reveal {
    text-align: center; margin-top: 4rem;
}
.gift-reveal-greeting {
    font-size: 1.5rem; color: var(--placeholder);
}
.gift-reveal-event {
    font-size: 1.125rem; color: var(--placeholder); margin-top: .5rem;
}
.gift-reveal-cards {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 2rem;
    margin-top: 3rem;
}
.gift-reveal-card {
    display: flex; flex-direction: column; align-items: center;
    gap: .5rem; padding: 2.5rem 3rem; border-radius: .75rem;
    background:
        radial-gradient(ellipse farthest-corner at right bottom, #FEDB37 0%, #FDB931 8%, #9f7928 30%, #8A6E2F 40%, transparent 80%),
        radial-gradient(ellipse farthest-corner at left top, #FFFFFF 0%, #FFFFAC 8%, #D1B464 25%, #5d4a1f 62.5%, #5d4a1f 100%);
    color: #fff;
    box-shadow: 0 10px 25px -5px var(--yellow-shadow);
}
.gift-reveal-icon { font-size: 3rem; }
.gift-reveal-label { font-size: 1.125rem; opacity: .85; }
.gift-reveal-name { font-size: 2.5rem; font-weight: 700; }
/* === Error page === */
.error-page { text-align: center; margin-top: 4rem; }
.error-page h1 { font-size: 4rem; }
.error-page .denied-answer { margin-top: 1.5rem; font-size: 1.125rem; max-width: 36rem; margin-left: auto; margin-right: auto; }
.login-reason { max-width: 32rem; text-align: center; }

/* === Rule edit page === */
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .625rem; }
.checkbox-grid label {
    display: flex; align-items: center; gap: .625rem;
    padding: .75rem .875rem; border: 1px solid var(--border); border-radius: .5rem;
    cursor: pointer; font-size: 1.0625rem; background: #fff;
    user-select: none;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .08s ease;
}
.checkbox-grid label:hover { border-color: var(--teal); box-shadow: 0 1px 3px rgba(15, 118, 110, .12); }
.checkbox-grid label:active { transform: translateY(1px); }
.checkbox-grid label:has(input:checked) {
    background: var(--teal); color: var(--btn-text); border-color: var(--teal);
    box-shadow: 0 6px 12px -4px var(--teal-shadow);
}
.checkbox-grid input[type="checkbox"] { width: auto; accent-color: var(--teal); }

/* === Rule builder === */
.rule-form { display: flex; flex-direction: column; gap: 1.75rem; max-width: 46rem; }

.rule-group {
    border: 1px solid var(--border); border-radius: .875rem;
    padding: 1.5rem 1.75rem 1.75rem; background: var(--input-bg);
}
.rule-group-legend {
    display: flex; align-items: center; gap: .75rem;
    margin-left: -.375rem; padding: 0 .625rem;
    font-family: 'Fraunces', Georgia, serif; font-weight: 800; font-size: 1.25rem;
}
.rule-group .checkbox-grid { margin-top: 1.25rem; }
.rule-step {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.875rem; height: 1.875rem; border-radius: 50%;
    background: var(--teal); color: var(--btn-text);
    font-family: system-ui, sans-serif; font-size: .9375rem; font-weight: 700;
    box-shadow: 0 4px 8px -3px var(--teal-shadow);
}

.rule-connector { display: flex; align-items: center; gap: 1.25rem; padding: 0 .5rem; }
.rule-connector-line { flex: 1; height: 1px; background: linear-gradient(to right, transparent, var(--border), transparent); }
.rule-connector-label {
    display: inline-flex; align-items: center; gap: .5rem;
    font-family: 'Fraunces', Georgia, serif; font-style: italic; font-size: 1.0625rem;
    color: var(--gold-dark); white-space: nowrap;
}
.rule-connector-icon { font-style: normal; font-size: 1.125rem; }

.rule-actions { display: flex; gap: 1.25rem; margin-top: .75rem; }

/* === Inline forms (for actions embedded in pages) === */
.inline-form { display: inline; }
.inline-form button { display: inline-flex; }

/* === Flex utilities === */
.flex-row { display: flex; align-items: center; gap: 1.25rem; }
.flex-col { display: flex; flex-direction: column; gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1.25rem; }

/* === Width === */
.w-full { width: 100%; }
@media (min-width: 640px) { .sm-w-fit { width: fit-content; } }

/* === Search === */
.search-row {
    display: flex; align-items: center; gap: 1.25rem;
    border: 1px solid var(--border); padding: 1.25rem;
    font-size: 1.25rem;
}
.search-row input { flex: 1; }
.filter-row { display: flex; align-items: center; gap: .75rem; flex: 1; max-width: 28rem; }
.filter-row input { flex: 1; }

/* A date shown for a zone that is not the reader's own says which zone it is. */
.zone {
    color: var(--muted, #6b6b6b);
    font-size: 0.85em;
}
