/*
 * HKAY Quiz — Stylesheet
 *
 * Bilingual Stacked principle:
 *   .xxx-en : Inter, larger, bolder, #1a1a1a  — always rendered first (on top)
 *   .xxx-ko : Noto Sans KR, smaller, #6b7280  — rendered immediately below
 *   Never separate /en /ko layouts.
 *
 * Typography spec (CLAUDE.md):
 *   Question EN : Inter 1.25rem / 600 / #1a1a1a
 *   Question KO : Noto Sans KR 1rem / 400 / #6b7280
 *   Option EN   : 1rem / 500 / #1a1a1a
 *   Option KO   : 0.85rem / 400 / #9ca3af
 */

/* ── Google Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+KR:wght@400;500&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
    --hkay-en-color:      #1a1a1a;
    --hkay-ko-color:      #6b7280;
    --hkay-opt-ko-color:  #9ca3af;
    --hkay-accent:        #3b82f6;   /* blue — progress bar, selected border */
    --hkay-correct:       #22c55e;
    --hkay-wrong:         #ef4444;
    --hkay-correct-bg:    #f0fdf4;
    --hkay-wrong-bg:      #fef2f2;
    --hkay-border:        #e5e7eb;
    --hkay-hover-bg:      #eff6ff;
    --hkay-selected-bg:   #dbeafe;
    --hkay-radius:        12px;
    --hkay-font-en:       'Inter', sans-serif;
    --hkay-font-ko:       'Noto Sans KR', sans-serif;
}

/* ── Container ─────────────────────────────────────────────────────────────── */
#hkay-quiz-app {
    max-width: 640px;
    margin: 2rem auto;
    padding: 0 1rem;
    font-family: var(--hkay-font-en);
    color: var(--hkay-en-color);
    box-sizing: border-box;
}

/* ── Progress bar ──────────────────────────────────────────────────────────── */
.hkay-progress {
    height: 6px;
    background: var(--hkay-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.hkay-progress__fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #06b6d4);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── Question card ─────────────────────────────────────────────────────────── */
.hkay-question-card {
    background: #fff;
    border: 1px solid var(--hkay-border);
    border-radius: var(--hkay-radius);
    padding: 1.75rem 1.5rem;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.hkay-question-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.hkay-q-counter {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--hkay-ko-color);
    letter-spacing: 0.03em;
}
.hkay-q-counter__sep { opacity: 0.5; }

.hkay-q-category {
    font-size: 0.75rem;
    background: #f3f4f6;
    color: var(--hkay-ko-color);
    padding: 0.2em 0.6em;
    border-radius: 99px;
    text-transform: capitalize;
}

.hkay-q-difficulty {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2em 0.6em;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: auto;
}
.hkay-difficulty--easy   { background: #dcfce7; color: #16a34a; }
.hkay-difficulty--medium { background: #fef9c3; color: #ca8a04; }
.hkay-difficulty--hard   { background: #fee2e2; color: #dc2626; }

/* ── Bilingual question text ─────────────────────────────────────────────── */
/* EN: Inter 1.25rem/600 — primary, dominant */
.question-en {
    font-family: var(--hkay-font-en);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--hkay-en-color);
    margin: 0 0 4px;
    line-height: 1.5;
}

/* KO: Noto Sans KR 1rem/400 — secondary, immediately below */
.question-ko {
    font-family: var(--hkay-font-ko);
    font-size: 1rem;
    font-weight: 400;
    color: var(--hkay-ko-color);
    margin: 0 0 1.5rem;
    line-height: 1.6;
}

/* ── Options list ──────────────────────────────────────────────────────────── */
.hkay-options {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

/* ── Option button — base ─────────────────────────────────────────────────── */
.hkay-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    border: 2px solid var(--hkay-border);
    border-radius: var(--hkay-radius);
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    user-select: none;
}
.hkay-option:hover {
    border-color: var(--hkay-accent);
    background: var(--hkay-hover-bg);
}
.hkay-option:active { transform: scale(0.99); }
.hkay-option.is-selected {
    border-color: var(--hkay-accent);
    background: var(--hkay-selected-bg);
}

/* ── Bilingual option text ────────────────────────────────────────────────── */
/* EN: 1rem/500 — on top, darker */
.option-en {
    font-family: var(--hkay-font-en);
    font-size: 1rem;
    font-weight: 500;
    color: var(--hkay-en-color);
    display: block;
    line-height: 1.4;
}

/* KO: 0.85rem/400 — below EN, lighter */
.option-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--hkay-opt-ko-color);
    display: block;
    line-height: 1.4;
    margin-top: 1px;
}

/* ── text layout: EN+KO stack inside the option ──────────────────────────── */
.hkay-options--text .hkay-option,
.hkay-options--emoji .hkay-option {
    flex-direction: row;
    align-items: center;
}
.hkay-options--text .hkay-option .option-en,
.hkay-options--text .hkay-option .option-ko,
.hkay-options--emoji .hkay-option .option-en,
.hkay-options--emoji .hkay-option .option-ko {
    display: block;
}
.hkay-option__label {
    display: flex;
    flex-direction: column;
}

/* ── emoji display ────────────────────────────────────────────────────────── */
.hkay-option__emoji {
    font-size: 2rem;
    flex-shrink: 0;
    line-height: 1;
    min-width: 2.5rem;
    text-align: center;
}

/* ── image-grid display (2×2) ─────────────────────────────────────────────── */
.hkay-options--image-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
    flex-direction: unset;
}
.hkay-options--image-grid .hkay-option {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    gap: 0;
}
.hkay-option__img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: calc(var(--hkay-radius) - 2px) calc(var(--hkay-radius) - 2px) 0 0;
    display: block;
}
.hkay-options--image-grid .hkay-option__label {
    padding: 0.5rem 0.75rem 0.625rem;
}

/* ── Submit screen ─────────────────────────────────────────────────────────── */
.hkay-submit-screen {
    text-align: center;
    padding: 2.5rem 1rem;
}
.hkay-submit__en {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--hkay-en-color);
    margin: 0 0 4px;
}
.hkay-submit__ko {
    font-size: 1rem;
    color: var(--hkay-ko-color);
    font-family: var(--hkay-font-ko);
    margin: 0 0 1.75rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.hkay-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 2rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: opacity 0.15s, transform 0.1s;
    line-height: 1.4;
}
.hkay-btn:active { transform: scale(0.97); }

.hkay-btn--submit {
    background: var(--hkay-accent);
    color: #fff;
}
.hkay-btn--submit:hover { opacity: 0.88; }

.hkay-btn--retry {
    background: #f3f4f6;
    color: var(--hkay-en-color);
    margin-top: 2rem;
}
.hkay-btn--retry:hover { background: #e5e7eb; }

.hkay-btn .en { font-family: var(--hkay-font-en); }
.hkay-btn .ko { font-family: var(--hkay-font-ko); font-size: 0.9em; }

/* ── Result page ───────────────────────────────────────────────────────────── */
.hkay-result {
    padding: 0.5rem 0 2rem;
}

.hkay-result__score-block {
    text-align: center;
    padding: 2rem 1rem 1.5rem;
}

.hkay-grade-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 1rem;
}
.badge-en { font-family: var(--hkay-font-en); }

/* Bilingual result title — EN first, KO below */
.result-title-en {
    font-family: var(--hkay-font-en);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--hkay-en-color);
    margin: 0 0 6px;
    line-height: 1.2;
}
.result-title-ko {
    font-family: var(--hkay-font-ko);
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--hkay-ko-color);
    margin: 0 0 0.5rem;
}
.hkay-result__sub-en {
    font-size: 0.875rem;
    color: var(--hkay-ko-color);
    margin: 0 0 2px;
}
.hkay-result__sub-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.825rem;
    color: var(--hkay-opt-ko-color);
    margin: 0;
}

/* ── Answer review ─────────────────────────────────────────────────────────── */
.hkay-review {
    margin-top: 2rem;
}
.hkay-review__heading-en {
    font-family: var(--hkay-font-en);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--hkay-en-color);
    margin: 0 0 2px;
}
.hkay-review__heading-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.9rem;
    color: var(--hkay-ko-color);
    margin: 0 0 1rem;
}

.hkay-review-item {
    border-radius: var(--hkay-radius);
    padding: 1rem 1.125rem;
    margin-bottom: 0.875rem;
    border-left: 4px solid transparent;
}
/* Correct answer — green tint */
.hkay-review-item.state-correct {
    background: var(--hkay-correct-bg);
    border-left-color: var(--hkay-correct);
}
/* Wrong answer — red tint */
.hkay-review-item.state-wrong {
    background: var(--hkay-wrong-bg);
    border-left-color: var(--hkay-wrong);
}

.hkay-review-item__question {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.875rem;
}
.hkay-review-item__num {
    font-size: 0.75rem;
    font-weight: 700;
    background: #e5e7eb;
    color: var(--hkay-ko-color);
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Bilingual review question — EN first, KO below */
.review-q-en {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--hkay-en-color);
    margin: 0 0 2px;
}
.review-q-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.85rem;
    color: var(--hkay-ko-color);
    margin: 0;
}

/* Review options mini-list */
.hkay-review-options {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.hkay-review-opt {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: rgba(255,255,255,0.6);
}

/* User selected the correct answer → strong green */
.hkay-review-opt.state-both {
    background: #bbf7d0;
    border-color: var(--hkay-correct);
}
/* Correct answer (user got it wrong) → green outline */
.hkay-review-opt.state-correct-ans {
    background: #dcfce7;
    border-color: #86efac;
}
/* User's wrong selection → red */
.hkay-review-opt.state-selected {
    background: #fee2e2;
    border-color: #fca5a5;
}

.hkay-check { color: var(--hkay-correct); font-weight: 700; margin-left: auto; }
.hkay-cross { color: var(--hkay-wrong);   font-weight: 700; margin-left: auto; }

/* Bilingual explanation — EN first, KO below */
.hkay-review-item__explanation {
    border-top: 1px solid rgba(0,0,0,0.06);
    padding-top: 0.625rem;
    margin-top: 0.5rem;
}
.explanation-en {
    font-size: 0.875rem;
    color: var(--hkay-en-color);
    margin: 0 0 3px;
    line-height: 1.55;
}
.explanation-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.825rem;
    color: var(--hkay-ko-color);
    margin: 0;
    line-height: 1.6;
}

/* ── Loading state ─────────────────────────────────────────────────────────── */
.hkay-loading {
    text-align: center;
    padding: 3rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.loading-en {
    font-size: 1rem;
    font-weight: 600;
    color: var(--hkay-ko-color);
}
.loading-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.9rem;
    color: var(--hkay-opt-ko-color);
}

/* ── Result retry button centering ────────────────────────────────────────── */
.hkay-result { text-align: center; }
.hkay-review { text-align: left; }

/* ── Share buttons ─────────────────────────────────────────────────────────── */
/*
 * 3 pill buttons in one row: Save (#6366f1) · X (#000) · Copy (#6b7280)
 * Bilingual label: EN on top, KO smaller beside
 */
.hkay-share-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1.25rem 0 0.75rem;
}

.hkay-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    font-family: var(--hkay-font-en);
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.3;
}
.hkay-share-btn:hover  { opacity: 0.85; }
.hkay-share-btn:active { transform: scale(0.96); }

/* Individual colours */
.hkay-share-btn--save { background: #6366f1; }   /* indigo */
.hkay-share-btn--x    { background: #000000; }   /* black  */
.hkay-share-btn--copy { background: #6b7280; }   /* slate  */

/* X brand glyph */
.x-icon {
    font-weight: 900;
    font-style: normal;
    font-size: 0.95em;
    letter-spacing: -0.02em;
}

/* KO label inside share button */
.hkay-share-btn .ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.8em;
    opacity: 0.9;
}

/* ── Canvas card preview ────────────────────────────────────────────────────── */
.hkay-card-preview {
    margin: 0 0 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}
/* Bilingual preview label — EN first, KO below */
.hkay-card-preview__label-en {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--hkay-ko-color);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0;
}
.hkay-card-preview__label-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.7rem;
    color: var(--hkay-opt-ko-color);
    margin: 0 0 0.4rem;
}

/* The generated canvas element */
.hkay-result-canvas {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
    display: block;
}

/* ── Grade badge KO sub-label ──────────────────────────────────────────────── */
.badge-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.85em;
    opacity: 0.85;
}

/* ── Grade comment — EN first, KO below ───────────────────────────────────── */
.hkay-grade-comment {
    background: #f9fafb;
    border: 1px solid var(--hkay-border);
    border-radius: var(--hkay-radius);
    padding: 1rem 1.25rem;
    margin: 1.25rem 0 1.5rem;
    text-align: left;
}
.grade-comment-en {
    font-size: 0.925rem;
    font-weight: 500;
    color: var(--hkay-en-color);
    margin: 0 0 3px;
    line-height: 1.55;
}
.grade-comment-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.875rem;
    color: var(--hkay-ko-color);
    margin: 0;
    line-height: 1.6;
}

/* ── Category bar chart ────────────────────────────────────────────────────── */
.hkay-category-bars {
    text-align: left;
    margin: 1.5rem 0;
}
.hkay-bars__heading-en {
    font-size: 1rem;
    font-weight: 600;
    color: var(--hkay-en-color);
    margin: 0 0 2px;
}
.hkay-bars__heading-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.85rem;
    color: var(--hkay-ko-color);
    margin: 0 0 1rem;
}

.hkay-bar-row {
    margin-bottom: 0.75rem;
}
.hkay-bar-row__label {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}
.hkay-bar-row__emoji {
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}
.hkay-bar-row__name {
    flex: 1;
}
/* Bilingual category label — EN first, KO after */
.hkay-bar-row__name .name-en {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--hkay-en-color);
}
.hkay-bar-row__name .name-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.75rem;
    color: var(--hkay-ko-color);
}
.hkay-bar-row__pct {
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 2.5rem;
    text-align: right;
}

/* Bar track */
.hkay-bar-track {
    height: 10px;
    background: var(--hkay-border);
    border-radius: 5px;
    overflow: hidden;
}
.hkay-bar-fill {
    height: 100%;
    border-radius: 5px;
    /* color applied via inline style (scoreColor fn) */
    transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Next Challenge block ──────────────────────────────────────────────────── */
.hkay-next-challenge {
    margin-top: 2.5rem;
    text-align: left;
}

.hkay-next-challenge__divider {
    height: 1px;
    background: var(--hkay-border);
    margin-bottom: 2rem;
}

/* Last week stats — EN first, KO below */
.hkay-last-week {
    background: #f9fafb;
    border: 1px solid var(--hkay-border);
    border-radius: var(--hkay-radius);
    padding: 1.125rem 1.25rem;
    margin-bottom: 1.5rem;
}
.last-week__label-en {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hkay-accent);
    margin: 0 0 2px;
}
.last-week__label-ko {
    display: none; /* hidden — KO label inline with EN via the uppercase label */
}
.last-week__title-en {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--hkay-en-color);
    margin: 0 0 2px;
}
.last-week__title-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.825rem;
    color: var(--hkay-ko-color);
    margin: 0 0 0.875rem;
}
.last-week__stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.last-week-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.stat__num {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--hkay-en-color);
    line-height: 1.1;
}
/* Bilingual stat label — EN first, KO below */
.stat__label-en {
    font-size: 0.75rem;
    color: var(--hkay-ko-color);
}
.stat__label-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.7rem;
    color: var(--hkay-opt-ko-color);
}

/* Next quiz CTA */
.next-cta__ready-en {
    font-size: 1rem;
    font-weight: 700;
    color: var(--hkay-en-color);
    margin: 0 0 2px;
}
.next-cta__ready-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.875rem;
    color: var(--hkay-ko-color);
    margin: 0 0 0.875rem;
}
.next-cta__card {
    border: 2px solid var(--hkay-accent);
    border-radius: var(--hkay-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
/* Bilingual next quiz title — EN first, KO below */
.next-cta__week-en {
    font-size: 1rem;
    font-weight: 700;
    color: var(--hkay-en-color);
    margin: 0 0 2px;
}
.next-cta__week-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.85rem;
    color: var(--hkay-ko-color);
    margin: 0 0 0.5rem;
}
.next-cta__teaser-en {
    font-size: 0.875rem;
    color: var(--hkay-ko-color);
    margin: 0 0 2px;
}
.next-cta__teaser-ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.8rem;
    color: var(--hkay-opt-ko-color);
    margin: 0 0 1rem;
}

/* CTA button */
.hkay-btn--cta {
    background: var(--hkay-accent);
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.hkay-btn--cta:hover { opacity: 0.88; }
.hkay-btn__arrow { font-size: 1.1em; margin-left: 0.1em; }

/* Classic quiz link */
.hkay-classic-link {
    font-size: 0.85rem;
    color: var(--hkay-ko-color);
    text-align: center;
    margin-top: 0.75rem;
}
.classic-link__anchor {
    color: var(--hkay-accent);
    text-decoration: none;
    font-weight: 500;
}
.classic-link__anchor:hover { text-decoration: underline; }
.classic-link__anchor .ko {
    font-family: var(--hkay-font-ko);
    font-size: 0.9em;
}

/* ── Mobile responsive (max-width: 640px) ─────────────────────────────────── */
@media ( max-width: 640px ) {
    .question-en          { font-size: 1.1rem; }
    .question-ko          { font-size: 0.925rem; }
    .option-en            { font-size: 0.925rem; }
    .option-ko            { font-size: 0.8rem; }
    .result-title-en      { font-size: 1.75rem; }
    .result-title-ko      { font-size: 1.1rem; }
    .hkay-question-card   { padding: 1.25rem 1rem; }
    .hkay-options--image-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .hkay-option__emoji   { font-size: 1.6rem; min-width: 2rem; }
    .last-week__stats     { gap: 1rem; }
    .hkay-next-challenge  { margin-top: 2rem; }
    .hkay-share-btn       { font-size: 0.8rem; padding: 0.5rem 0.85rem; }
    .hkay-result-canvas   { border-radius: 8px; }
}
