/* ==========================================================================
   Quest — "Paspor" theme
   A travel-document aesthetic: washi paper, sumi ink, indigo + vermilion
   immigration stamps. Built for quest.kyomacorner.com.
   ========================================================================== */

:root {
    --paper: #e8dfc8;
    --paper-2: #ddd0b2;
    --paper-edge: #d2c39f;
    --ink: #2c2a24;
    --ink-soft: #6b6454;
    --ink-faint: #9a9079;
    --indigo: #1c3b57;
    --indigo-deep: #142a3e;
    --vermilion: #c0402b;
    --olive: #6e7544;
    --line: #b7a684;
    --gold: #9c7a3c;
    --desk: #11202c;

    --field: "Archivo", "Segoe UI", sans-serif;
    --body: "Spectral", Georgia, serif;
    --mrz: "JetBrains Mono", "Courier New", monospace;

    --page-max: 940px;
    --radius: 3px;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--body);
    color: var(--ink);
    line-height: 1.6;
    background-color: var(--desk);
    background-image:
        radial-gradient(circle at 18% 12%, #17303f 0, transparent 55%),
        radial-gradient(circle at 82% 88%, #0d1a24 0, transparent 50%);
    min-height: 100vh;
    padding: 28px 16px 64px;
}

/* --- The booklet ---------------------------------------------------------- */

.booklet {
    max-width: var(--page-max);
    margin: 0 auto;
}

.page {
    position: relative;
    background-color: var(--paper);
    /* washi fibre: faint flecks + a woven tint, no gradients-as-decoration */
    background-image:
        radial-gradient(rgba(120, 104, 70, 0.05) 1px, transparent 1px),
        radial-gradient(rgba(120, 104, 70, 0.04) 1px, transparent 1px);
    background-size: 7px 7px, 13px 13px;
    background-position: 0 0, 4px 4px;
    border: 1px solid var(--paper-edge);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 24px 60px -30px rgba(0, 0, 0, 0.7);
    padding: 0;
}

/* --- Cover band (header) -------------------------------------------------- */

.cover {
    background-color: var(--indigo);
    color: var(--paper);
    padding: 18px 26px;
    border-bottom: 3px double var(--gold);
    position: relative;
    overflow: hidden;
}

/* guilloché security waves, very faint, on the cover only */
.cover::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='40'><path d='M0 20 Q 15 2 30 20 T 60 20 T 90 20 T 120 20' fill='none' stroke='%23ffffff' stroke-opacity='0.06' stroke-width='1'/><path d='M0 30 Q 15 12 30 30 T 60 30 T 90 30 T 120 30' fill='none' stroke='%23ffffff' stroke-opacity='0.05' stroke-width='1'/></svg>");
    pointer-events: none;
}

.cover-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 12px; }

.brand .mark {
    font-family: var(--field);
    font-weight: 700;
    letter-spacing: 0.22em;
    font-size: 1.55rem;
    text-transform: uppercase;
    color: var(--paper);
}

.brand .sub {
    font-family: var(--field);
    font-weight: 300;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    color: #c9d4de;
    text-transform: uppercase;
}

.cover .holder {
    font-family: var(--mrz);
    font-size: 0.72rem;
    color: #c9d4de;
    display: flex;
    align-items: center;
    gap: 14px;
}

.cover .holder form { margin: 0; }

.linkout {
    color: var(--paper);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    font-family: var(--field);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    background: none;
    border-left: 0; border-right: 0; border-top: 0;
    cursor: pointer;
    padding: 0 0 2px;
}
.linkout:hover { border-bottom-color: var(--gold); }

/* --- Nav tabs ------------------------------------------------------------- */

.tabs {
    display: flex;
    gap: 0;
    background-color: var(--indigo-deep);
    padding: 0 18px;
}

.tabs a {
    font-family: var(--field);
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9fb0bd;
    text-decoration: none;
    padding: 11px 16px;
    border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--paper); }
.tabs a.active { color: var(--paper); border-bottom-color: var(--vermilion); }

/* --- Page body ------------------------------------------------------------ */

.sheet { padding: 30px 30px 40px; }

@media (max-width: 620px) {
    .sheet { padding: 22px 18px 32px; }
}

/* Document field label — the one place uppercase is allowed, because this
   really is a passport field label, not a decorative eyebrow. */
.field-label {
    font-family: var(--field);
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-soft);
    display: block;
    margin-bottom: 3px;
}

.field-value { font-size: 1.02rem; }

h1, h2, h3 { font-family: var(--body); font-weight: 600; color: var(--ink); margin: 0; }

/* --- Identity / data page ------------------------------------------------- */

.identity {
    display: grid;
    grid-template-columns: 112px 1fr;
    gap: 22px;
    align-items: start;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

/* the "photo" cell: a destination emblem framed like a passport photo */
.photo {
    border: 1px solid var(--line);
    background-color: #efe8d6;
    width: 100%;
    max-width: 112px;
    aspect-ratio: 3 / 4;
    align-self: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo::before, .photo::after {
    /* corner registration ticks */
    content: "";
    position: absolute;
    width: 10px; height: 10px;
    border: 1px solid var(--ink-soft);
}
.photo::before { top: 5px; left: 5px; border-right: 0; border-bottom: 0; }
.photo::after { bottom: 5px; right: 5px; border-left: 0; border-top: 0; }
.photo svg { width: 64px; height: 64px; }

.id-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 24px;
    align-content: center;
}
.id-fields .full { grid-column: 1 / -1; }

.doc-no { font-family: var(--mrz); font-size: 0.95rem; letter-spacing: 0.04em; }

/* designation = current level */
.designation {
    font-family: var(--field);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    color: var(--indigo);
}

/* XP bar */
.xpbar { margin-top: 4px; }
.xpbar .track {
    height: 8px;
    background-color: var(--paper-2);
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
}
.xpbar .fill {
    height: 100%;
    background-color: var(--indigo);
    background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.12) 0 4px, transparent 4px 8px);
    width: 0;
    transition: width 900ms cubic-bezier(.2,.7,.2,1);
}
.xpbar .meta {
    font-family: var(--mrz);
    font-size: 0.68rem;
    color: var(--ink-soft);
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
}

/* --- Goal headline -------------------------------------------------------- */

.mission { padding: 24px 0; border-bottom: 1px solid var(--line); }
.mission .title { font-size: 1.5rem; line-height: 1.25; }
.mission .desc { color: var(--ink-soft); margin: 8px 0 16px; max-width: 62ch; }

.mission-meta { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-end; }

.bignum {
    font-family: var(--field);
    font-weight: 700;
    font-size: 2.6rem;
    line-height: 1;
    color: var(--indigo);
}
.bignum .pct { font-size: 1.1rem; color: var(--ink-soft); }

/* --- Stamps (milestones) -------------------------------------------------- */

.section { padding: 26px 0; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}
.section-head h2 { font-size: 1.12rem; letter-spacing: 0.01em; }
.section-head .hint { font-family: var(--field); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }

.stamps {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 18px;
}

.stamp {
    text-decoration: none;
    color: inherit;
    border: 1px dashed var(--line);
    padding: 16px 14px 14px;
    position: relative;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 0.14);
}
.stamp:hover { border-color: var(--ink-soft); }

.stamp .seal {
    width: 58px; height: 58px;
    border-radius: 50%;
    border: 2px solid var(--ink-faint);
    color: var(--ink-faint);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--field);
    font-weight: 700;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    transform: rotate(-8deg);
    margin-bottom: 10px;
    opacity: 0.55;
}

.stamp.done { border-style: solid; border-color: var(--indigo); background-color: rgba(28, 59, 87, 0.05); }
.stamp.done .seal {
    border-color: var(--vermilion);
    color: var(--vermilion);
    border-width: 2.5px;
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(192, 64, 43, 0.12);
}
.stamp.done .seal::after {
    content: "";
    position: absolute;
    /* tiny double ring, like a rubber stamp */
    width: 48px; height: 48px;
    border: 1px solid currentColor;
    border-radius: 50%;
}

.stamp .m-title { font-size: 0.98rem; line-height: 1.3; }
.stamp .m-foot {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--mrz);
    font-size: 0.66rem;
    color: var(--ink-soft);
}

.stars { color: var(--vermilion); letter-spacing: 2px; font-size: 0.8rem; }
.stars .off { color: var(--ink-faint); opacity: 0.5; }

.pastdue {
    font-family: var(--field);
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--vermilion);
    border: 1px solid var(--vermilion);
    padding: 1px 5px;
    margin-left: 6px;
    white-space: nowrap;
}

.mini-progress {
    height: 5px;
    background-color: var(--paper-2);
    border: 1px solid var(--line);
    margin-top: 10px;
    overflow: hidden;
}
.mini-progress span { display: block; height: 100%; background-color: var(--olive); }

/* stamp-press animation when a milestone is freshly stamped */
@keyframes press {
    0% { transform: rotate(-8deg) scale(1.5); opacity: 0; }
    60% { transform: rotate(-8deg) scale(0.92); opacity: 1; }
    100% { transform: rotate(-8deg) scale(1); opacity: 1; }
}
.stamp.just-stamped .seal { animation: press 520ms cubic-bezier(.2,.8,.3,1.2); }

/* --- Habits --------------------------------------------------------------- */

.habits { display: flex; flex-direction: column; gap: 10px; }

.habit {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background-color: rgba(255, 255, 255, 0.14);
}
.habit .tick {
    flex: none;
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 2px solid var(--ink-faint);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: background-color 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.habit .tick:hover { border-color: var(--ink-soft); }
.habit.indigo .tick.on { background-color: var(--indigo); border-color: var(--indigo); }
.habit.olive .tick.on { background-color: var(--olive); border-color: var(--olive); }
.habit.vermilion .tick.on { background-color: var(--vermilion); border-color: var(--vermilion); }
.habit .tick.on::after {
    content: "";
    position: absolute;
    left: 10px; top: 5px;
    width: 8px; height: 15px;
    border: solid var(--paper);
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(42deg);
}
.habit .tick.on { animation: ink 260ms ease; }
@keyframes ink { 0% { transform: scale(0.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

.habit .body { flex: 1 1 auto; min-width: 0; }
.habit .name { font-size: 1rem; }
.habit .streak {
    font-family: var(--mrz);
    font-size: 0.68rem;
    color: var(--ink-soft);
}
.habit .streak b { color: var(--vermilion); }

.habit .freeze {
    font-family: var(--field);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    background: none;
    border: 1px solid var(--line);
    padding: 5px 8px;
    cursor: pointer;
}
.habit .freeze:hover { border-color: var(--indigo); color: var(--indigo); }
.habit .freeze[disabled] { opacity: 0.4; cursor: not-allowed; }

/* --- Agenda list ---------------------------------------------------------- */

.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px dotted var(--line);
}
.agenda li:last-child { border-bottom: 0; }
.agenda .when {
    font-family: var(--mrz);
    font-size: 0.72rem;
    color: var(--indigo);
    flex: none;
    width: 92px;
}
.agenda .when.soon { color: var(--vermilion); }
.agenda .what { flex: 1; }
.agenda .what small { color: var(--ink-faint); display: block; font-family: var(--field); font-size: 0.64rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* --- Quick tasks (tugas lepas) -------------------------------------------- */

.errands { list-style: none; margin: 0; padding: 0; }
.errands li {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 0;
    border-bottom: 1px dotted var(--line);
}
.errands li:last-child { border-bottom: 0; }
.errands .box {
    width: 18px; height: 18px; flex: none;
    border: 1.5px solid var(--ink-faint);
    background: transparent;
    cursor: pointer;
    position: relative;
}
.errands .box:hover { border-color: var(--ink-soft); }
.errands .box.on { background-color: var(--olive); border-color: var(--olive); }
.errands .box.on::after {
    content: ""; position: absolute; left: 5px; top: 1px;
    width: 5px; height: 10px; border: solid var(--paper); border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.errands .et { flex: 1; min-width: 0; }
.errands li.on .et { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--line); }
.errands .ed { font-family: var(--mrz); font-size: 0.7rem; color: var(--indigo); flex: none; }

/* --- Goal page: milestone pages ------------------------------------------- */

.mpage { border: 1px solid var(--line); margin-bottom: 20px; background-color: rgba(255,255,255,0.1); }
.mpage > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    background-color: rgba(28, 59, 87, 0.05);
    border-bottom: 1px solid var(--line);
}
.mpage.done > header { background-color: rgba(110, 117, 68, 0.1); }
.mpage header h3 { font-size: 1.1rem; }
.mpage header .note { color: var(--ink-soft); font-size: 0.9rem; margin-top: 4px; max-width: 64ch; }

.tasklist { list-style: none; margin: 0; padding: 8px 18px 16px; }
.task {
    padding: 12px 0;
    border-bottom: 1px dotted var(--line);
}
.task:last-child { border-bottom: 0; }
.task .task-head { display: flex; align-items: baseline; gap: 10px; }
.task .ttitle { font-size: 1rem; }
.task.done .ttitle { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--line); }
.task .tmeta { margin-left: auto; display: flex; align-items: center; gap: 12px; font-family: var(--mrz); font-size: 0.68rem; color: var(--ink-soft); }

.subs { list-style: none; margin: 8px 0 0 30px; padding: 0; }
.subs li { display: flex; align-items: center; gap: 9px; padding: 4px 0; font-size: 0.92rem; }
.subs .box {
    width: 16px; height: 16px; flex: none;
    border: 1.5px solid var(--ink-faint);
    background: transparent;
    cursor: pointer;
    position: relative;
}
.subs .box.on { background-color: var(--olive); border-color: var(--olive); }
.subs .box.on::after {
    content: ""; position: absolute; left: 4px; top: 1px;
    width: 5px; height: 9px; border: solid var(--paper); border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.subs li.on span { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--line); }

/* --- Buttons & forms ------------------------------------------------------ */

.btn {
    font-family: var(--field);
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 8px 14px;
    border: 1px solid var(--indigo);
    background-color: var(--indigo);
    color: var(--paper);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn:hover { background-color: var(--indigo-deep); }
.btn.ghost { background: transparent; color: var(--indigo); }
.btn.ghost:hover { background-color: rgba(28,59,87,0.08); }
.btn.danger { border-color: var(--vermilion); color: var(--vermilion); background: transparent; }
.btn.danger:hover { background-color: rgba(192,64,43,0.08); }
.btn.sm { padding: 5px 9px; font-size: 0.64rem; }

.statusbtn {
    font-family: var(--field);
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink-soft);
    padding: 5px 9px;
    cursor: pointer;
}
.statusbtn:hover { border-color: var(--indigo); color: var(--indigo); }
.statusbtn.done { border-color: var(--olive); color: var(--olive); background-color: rgba(110,117,68,0.08); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
    font-family: var(--body);
    font-size: 0.95rem;
    color: var(--ink);
    background-color: #f3eeddff;
    border: 1px solid var(--line);
    padding: 9px 11px;
    width: 100%;
    border-radius: var(--radius);
}
input:focus, textarea:focus, select:focus, .btn:focus-visible, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--vermilion);
    outline-offset: 2px;
}
label.stack { display: block; margin-bottom: 12px; }

.addform {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}
.addform input[type="text"] { flex: 1 1 200px; width: auto; }

details.adder { margin-top: 14px; }
details.adder > summary {
    font-family: var(--field);
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--indigo);
    cursor: pointer;
    list-style: none;
}
details.adder > summary::-webkit-details-marker { display: none; }
details.adder > summary::before { content: "+ "; }
details.adder[open] > summary::before { content: "– "; }

/* --- Flash / earned toast ------------------------------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    background-color: var(--indigo);
    color: var(--paper);
    font-family: var(--field);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    padding: 12px 20px;
    border: 1px solid var(--gold);
    box-shadow: 0 14px 30px -14px rgba(0,0,0,0.6);
    z-index: 50;
    animation: toast-in 300ms ease, toast-out 400ms ease 3.4s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 10px); } }

.errors {
    background-color: rgba(192,64,43,0.08);
    border: 1px solid var(--vermilion);
    color: var(--vermilion);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* --- MRZ footer ----------------------------------------------------------- */

.mrz {
    background-color: var(--paper-2);
    border-top: 1px solid var(--line);
    padding: 14px 26px;
    font-family: var(--mrz);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    word-break: break-all;
    line-height: 1.9;
}
.mrz .l2 { color: var(--ink-faint); }

/* --- Login ---------------------------------------------------------------- */

.login-wrap { max-width: 400px; margin: 6vh auto 0; }
.login-wrap .cover { border-radius: var(--radius) var(--radius) 0 0; }
.login-wrap .sheet { text-align: left; }
.login-wrap .lead { color: var(--ink-soft); margin: 0 0 18px; font-size: 0.95rem; }

/* --- Utility -------------------------------------------------------------- */

.muted { color: var(--ink-soft); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt { margin-top: 16px; }
form.inline { display: inline; margin: 0; }

@media (max-width: 620px) {
    .identity { grid-template-columns: 90px 1fr; }
    .id-fields { grid-template-columns: 1fr; }
    .bignum { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
