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

:root {
    --color-bg: #e8e8e8;
    --color-card: #ffffff;
    --color-text: #231f20;
    --color-text-light: #777777;
    --color-lang: #808080;
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --card-radius: 28px;
    --page-padding: 16px;
    --max-width: 420px;
}

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

body {
    font-family: var(--font);
    font-weight: 400;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.55;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.page {
    width: 100%;
    max-width: var(--max-width);
    padding: 12px var(--page-padding) 20px;
}


/* ============================================================
   HEADER: marks + language selector
   ============================================================ */

.marks-header {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0;
}

.marks-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mark-btn {
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

.mark-btn img {
    display: block;
    transition: filter 0.2s ease;
}

.mark-btn:hover img {
    filter: drop-shadow(0 0 1.5px #fff200) drop-shadow(0 0 1.5px #fff200);
}

.mark-btn.active img {
    filter: drop-shadow(0 0 3px #fff200) drop-shadow(0 0 3px #fff200) drop-shadow(0 0 3px #fff200);
}

.mark-pp img  { height: 38px; width: auto; }
.mark-ce img  { height: 28px; width: auto; }
.mark-ukca img { height: 30px; width: auto; }
.mark-uv400 img { height: 30px; width: auto; position: relative; top: 1px; }

.marks-spacer { flex: 1; }

/* Language selector */
.lang-selector { position: relative; user-select: none; }

.lang-trigger {
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 400;
    font-size: 17px;
    color: #b0b0b0;
    background: none;
    border: none;
    padding: 12px 4px;
    letter-spacing: 0.5px;
}

.lang-trigger .arrow {
    font-size: 12px;
    margin-left: 1px;
    transition: transform 0.2s ease;
    line-height: 1;
}

.lang-selector.open .lang-trigger .arrow { transform: rotate(180deg); }

.lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: -8px;
    background: var(--color-card);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
    z-index: 100;
    min-width: 200px;
    overflow: hidden;
    padding: 8px 0;
}

.lang-selector.open .lang-dropdown {
    display: block;
    animation: dropIn 0.15s ease-out;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dual-column mode when not enough vertical space */
.lang-dropdown.dual-column {
    columns: 2;
    column-gap: 0;
    width: 340px;
    min-width: 340px;
}

.lang-dropdown.dual-column a {
    break-inside: avoid;
}

.lang-dropdown a {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 9px 16px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 14px;
    transition: background 0.1s;
}

.lang-dropdown a:hover { background: #f2f2f2; }
.lang-dropdown a.active { color: #0066cc; }
.lang-dropdown .lang-code { font-weight: 400; font-size: 14px; min-width: 22px; letter-spacing: 0.3px; }
.lang-dropdown .lang-name { font-weight: 300; color: var(--color-text-light); font-size: 14px; }
.lang-dropdown a.active .lang-name { color: #0066cc; }


/* ============================================================
   CAT BAR
   ============================================================ */

.catbar-wrap {
    position: relative;
    width: 100%;
    /* Reserve space below SVG for the tooltip (= bar height) */
    padding-bottom: 8.859%; /* 24.35 / 274.86 * 100 */
}

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

.cell-bg {
    cursor: pointer;
    transition: fill 0.15s ease;
}

/* Tooltip: flush under bar, same width, height = bar height (2 lines) */
.cat-tooltip {
    position: absolute;
    top: 50%;  /* 50% of catbar-wrap = bottom of SVG (SVG is ~50%, padding is ~50%) */
    left: 0;
    width: 100%;
    aspect-ratio: 274.86 / 24.35;
    background: #fff200;
    display: flex;
    align-items: center;
    padding-left: 1.3%;
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
}

.cat-tooltip.visible {
    opacity: 1;
    pointer-events: auto;
}

.cat-tooltip-text {
    font-family: var(--font);
    font-weight: 400;
    color: var(--color-text);
    word-break: break-word;
    line-height: 1.25;
}


/* ============================================================
   CAPTION between bar and card
   ============================================================ */

.cat-caption {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 1px;
    text-align: center;
    font-size: 13px;
    font-weight: 300;
    color: var(--color-text-light);
    letter-spacing: 0.15px;
    z-index: 1;
}


/* ============================================================
   CONTENT CARD
   ============================================================ */

.content-card {
    background: var(--color-card);
    border-radius: var(--card-radius);
    box-shadow: 0 8px 5px rgba(0,0,0,0.20);
    padding: 24px 20px 28px;
    margin-top: 4px;
    position: relative;
    overflow: hidden;
}

/* Default page: ALWAYS in flow, controls card height */
#pageDefault {
    position: relative;
    padding: 0;
    pointer-events: auto;
    transition: opacity 0.3s ease-in-out;
}

/* Icon pages: always absolute, overlay on top */
.card-page:not(#pageDefault) {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 24px 20px 28px;
    pointer-events: none;
}

.card-page:not(#pageDefault).active {
    opacity: 1;
    pointer-events: auto;
}

/* When an icon page is shown, fade out default but keep its space */
.content-card.icon-active #pageDefault {
    opacity: 0;
    pointer-events: none;
}

/* Default card: care instructions */
.leaflet-body {
    text-align: left;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.6;
    padding: 0 6px;
}

.leaflet-body p { margin-bottom: 14px; }
.leaflet-body p:last-child { margin-bottom: 0; }

/* Icon info card */
.card-icon-display {
    text-align: center;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon-display img {
    display: block;
}

.card-info-text {
    text-align: left;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.6;
    padding: 0 6px;
}


/* ============================================================
   COMPLIANCE FOOTER
   ============================================================ */

.compliance-footer {
    text-align: center;
    font-size: 11px;
    font-weight: 300;
    color: #666666;
    letter-spacing: 0.3px;
    line-height: 1.25;
    padding: 4px 16px 20px;
}


/* ============================================================
   ONBOARDING GLOW: quick pulse on first load
   ============================================================ */

@keyframes hintGlow {
    0%   { filter: drop-shadow(0 0 0px rgba(255,242,0,0)) drop-shadow(0 0 0px rgba(255,242,0,0)); }
    40%  { filter: drop-shadow(0 0 4px rgba(255,242,0,0.9)) drop-shadow(0 0 4px rgba(255,242,0,0.9)); }
    100% { filter: drop-shadow(0 0 0px rgba(255,242,0,0)) drop-shadow(0 0 0px rgba(255,242,0,0)); }
}

.hint-glow img {
    animation: hintGlow 2.5s ease-in-out;
}

.hint-glow-lang {
    animation: hintGlow 2.5s ease-in-out;
}

.hint-glow-cell {
    animation: hintGlowFill 2.5s ease-in-out;
}

@keyframes hintGlowFill {
    0%   { fill: #fff; }
    35%  { fill: rgba(255,242,0,0.35); }
    100% { fill: #fff; }
}


/* ============================================================
   LANDING PAGE: code entry
   ============================================================ */

.landing-page {
    width: 100%;
    max-width: var(--max-width);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.landing-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 48px;
    padding: 0 var(--page-padding);
}

.landing-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 var(--page-padding);
}

.landing-prompt {
    font-size: 22px;
    font-weight: 300;
    color: var(--color-text-light);
    text-align: center;
    margin-bottom: 16px;
    letter-spacing: 0.15px;
}

.landing-input {
    width: 100%;
    height: 56px;
    border: none;
    border-radius: var(--card-radius);
    background: var(--color-card);
    box-shadow: 0 8px 5px rgba(0,0,0,0.20);
    font-family: var(--font);
    font-size: 26px;
    font-weight: 600;
    color: var(--color-text);
    text-align: center;
    letter-spacing: 0.5px;
    outline: none;
    transition: background 0.3s ease, box-shadow 0.2s ease;
}

.landing-input:focus {
    box-shadow: 0 8px 5px rgba(0,0,0,0.20);
}

@keyframes hintGlowInput {
    0%   { background: var(--color-card); }
    35%  { background: rgba(255,242,0,0.4); }
    100% { background: var(--color-card); }
}

@keyframes flashRed {
    0%   { box-shadow: 0 8px 5px rgba(0,0,0,0.20), 0 0 0px 0px rgba(255,0,0,0); }
    30%  { box-shadow: 0 8px 5px rgba(0,0,0,0.20), 0 0 10px 3px rgba(255,0,0,0.8); }
    100% { box-shadow: 0 8px 5px rgba(0,0,0,0.20), 0 0 0px 0px rgba(255,0,0,0); }
}

@keyframes flashGreen {
    0%   { box-shadow: 0 8px 5px rgba(0,0,0,0.20), 0 0 0px 0px rgba(0,200,0,0); }
    30%  { box-shadow: 0 8px 5px rgba(0,0,0,0.20), 0 0 10px 3px rgba(0,200,0,0.8); }
    100% { box-shadow: 0 8px 5px rgba(0,0,0,0.20), 0 0 0px 0px rgba(0,200,0,0); }
}

.flash-wrong {
    animation: flashRed 1.2s ease-in-out;
}

.flash-correct {
    animation: flashGreen 0.8s ease-in-out;
}

.hint-glow-input {
    animation: hintGlowInput 1.8s ease-in-out;
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (min-width: 520px) {
    .marks-header { height: 56px; }
    .mark-pp img  { height: 42px; }
    .mark-ce img  { height: 32px; }
    .mark-ukca img { height: 34px; }
    .mark-uv400 img { height: 34px; }
}
