/* ==========================================================================
   نه تو مانی و نه من
   A Persian poetry manuscript as a countdown page.
   All fonts and images are local — the page is fully offline-capable.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Fonts — IranNastaliq carries the whole interface.
   -------------------------------------------------------------------------- */

@font-face {
    font-family: "IranNastaliq";
    /* woff2 first (≈352KB vs 1MB); the .ttf is the same face, kept as a
       fallback for anything that cannot take woff2. */
    src: url("../fonts/IranNastaliq.woff2") format("woff2"),
         url("../fonts/IranNastaliq.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Last-resort fallbacks only — never the primary face for visible text. */
@font-face {
    font-family: "NastaliqFallback";
    src: url("../fonts/NotoNastaliqUrdu-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* --------------------------------------------------------------------------
   Palette
   -------------------------------------------------------------------------- */

:root {
    --page: #E8D7B7;
    --page-light: #F0E2C7;

    --card: #FAEFD6;

    --ink: #1D1913;
    --secondary: #74634D;
    --muted: #9B876A;

    --accent: #886F3D;
    --accent-dark: #65502C;
    --accent-light: #B79A65;

    --border: #755833;
    --border-muted: #CDBA97;

    --icon: #765A32;
    --icon-background: #F6E8C8;

    --shadow: rgba(56, 42, 25, 0.08);

    /* Derived surfaces — cards are lighter areas of the same parchment,
       never opaque panels sitting on top of it. */
    --card-surface: rgba(250, 239, 214, 0.60);
    --box-surface: rgba(250, 239, 214, 0.42);
    --box-surface-hover: rgba(245, 229, 196, 0.62);
    --hairline: rgba(117, 88, 51, 0.16);
    --rule: rgba(136, 111, 61, 0.30);

    --nastaliq: "IranNastaliq", "NastaliqFallback", "Vazirmatn", serif;
    --ease: 180ms ease;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

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

body {
    direction: rtl;
    text-align: right;
    margin: 0;

    font-family: var(--nastaliq);
    font-weight: 400;
    color: var(--ink);

    background-color: var(--page);
    /* A flat, very low-contrast wash — no radial glow behind the cards. */
    background-image:
        linear-gradient(
            rgba(240, 226, 199, 0.18),
            rgba(232, 215, 183, 0.18)
        ),
        url("../images/paper-texture.webp");
    background-repeat: repeat;
    background-size: auto, 260px 260px;

    overflow-x: hidden;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Page shell — the composition sits near the top; nothing is stretched to
   fill the viewport.
   -------------------------------------------------------------------------- */

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1120px, calc(100% - 40px));
    margin-inline: auto;
    padding: 48px 0 0;
}

.page-header {
    text-align: center;
    margin-bottom: 30px;
}

/* --------------------------------------------------------------------------
   Title — real calligraphy artwork, not type. It sits directly on the
   parchment: no box, no card, no shadow.
   -------------------------------------------------------------------------- */

.hero-title {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0;
}

.title-calligraphy {
    display: block;
    width: min(560px, 70vw);
    height: auto;
    object-fit: contain;
    background: transparent;
    /* The extraction un-mixes the paper out of the edges, so plain alpha
       compositing already lands the ink on the parchment cleanly —
       mix-blend-mode: multiply would only re-darken it. */
    opacity: 0.96;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
}

.title-ornament {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 4px auto 0;
    color: var(--accent);
    opacity: 0.45;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.cards-grid {
    display: grid;
    /* minmax(0,…) is what actually stops grid children from overflowing. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}

.person-card {
    display: flex;
    flex-direction: column;
    padding: 28px;

    background-color: var(--card-surface);
    border: 1px solid var(--hairline);
    border-radius: 18px;
    /* Printed onto the paper, not floating above it. */
    box-shadow: 0 6px 24px rgba(56, 42, 25, 0.055);

    transition: transform var(--ease), background-color var(--ease),
                border-color var(--ease);
}

.person-card:hover {
    transform: translateY(-2px);
    background-color: rgba(250, 239, 214, 0.72);
    border-color: rgba(117, 88, 51, 0.24);
}

/* ---- identity block: portrait + name + date read as one unit ---- */

.card-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 22px;
}

.portrait {
    position: relative;
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

/* A small symmetrical sprig sitting behind and below the medallion. */
.portrait-sprig {
    position: absolute;
    bottom: -13px;
    width: 195%;
    height: auto;
    color: var(--accent);
    opacity: 0.38;
    pointer-events: none;
    z-index: 0;
}

.profile-image {
    position: relative;
    z-index: 1;

    width: 82px;
    height: 82px;

    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--accent-light);
    padding: 3px;
    background: var(--card);

    box-shadow: 0 4px 14px rgba(56, 42, 25, 0.10);
}

.identity {
    text-align: right;
    min-width: 0;
}

.person-name {
    display: block;
    font-family: var(--nastaliq);
    font-size: 48px;
    font-weight: 400;
    line-height: 1.55;
    color: var(--ink);
    margin: 0;
}

.target-date {
    display: block;
    font-family: var(--nastaliq);
    font-size: 28px;
    line-height: 1.5;
    color: var(--secondary);
    margin: 2px 0 0;
}

/* --------------------------------------------------------------------------
   Countdown
   -------------------------------------------------------------------------- */

.countdown {
    width: 100%;
}

.countdown-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    width: 100%;
}

.countdown-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;

    /* Equal cells: the box never resizes as the digits change. */
    padding: 14px 8px 12px;
    min-width: 0;

    background: var(--box-surface);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(56, 42, 25, 0.035);

    transition: background-color var(--ease);
}

.countdown-box:hover {
    background: var(--box-surface-hover);
}

.countdown-value {
    font-family: var(--nastaliq);
    font-size: 60px;
    line-height: 1.3;
    color: var(--ink);

    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    transition: opacity var(--ease);
}

.countdown-label {
    font-family: var(--nastaliq);
    font-size: 25px;
    line-height: 1.45;
    color: var(--secondary);
}

/* --------------------------------------------------------------------------
   Manuscript divider  ──── ◇ مجموع زمان باقی‌مانده ◇ ────
   -------------------------------------------------------------------------- */

.section-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 26px 0 16px;
}

.section-divider .rule {
    flex: 1 1 auto;
    height: 1px;
    min-width: 0;
    background: var(--rule);
}

.section-divider strong {
    display: flex;
    align-items: center;
    gap: 12px;

    font-family: var(--nastaliq);
    font-size: 29px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--accent-dark);
    white-space: nowrap;
}

/* The two ◇ lozenges flanking the caption. */
.section-divider strong::before,
.section-divider strong::after {
    content: "";
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    transform: rotate(45deg);
    background: var(--accent);
    opacity: 0.75;
}

/* --------------------------------------------------------------------------
   Totals — deliberately quieter than the main countdown.
   -------------------------------------------------------------------------- */

.totals .countdown-box {
    padding: 11px 6px 9px;
    background: rgba(250, 239, 214, 0.34);
}

.totals .countdown-value {
    font-size: 36px;
    line-height: 1.35;
    opacity: 0.82;
}

.totals .countdown-label {
    font-size: 21px;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    margin-top: 52px;
    margin-bottom: 28px;

    font-family: var(--nastaliq);
    font-size: 24px;
    line-height: 1.5;
    color: var(--secondary);
}

.footer-leaf {
    width: 30px;
    height: 11px;
    color: var(--accent);
    opacity: 0.45;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Corner ornaments
   -------------------------------------------------------------------------- */

.corner-ornament {
    position: fixed;
    bottom: 0;
    width: 190px;
    height: auto;
    color: var(--accent);
    opacity: 0.24;
    pointer-events: none;
    z-index: 0;
}

.corner-ornament--right {
    right: 0;
}

.corner-ornament--left {
    left: 0;
    transform: scaleX(-1);
}

/* --------------------------------------------------------------------------
   Dedicated person pages — same design, stronger personal focus.
   -------------------------------------------------------------------------- */

.page--person .person-card {
    max-width: 740px;
    margin: 0 auto;
    padding: 34px 32px 30px;
}

.page--person .card-header {
    gap: 22px;
    margin-bottom: 26px;
}

.page--person .profile-image {
    width: 110px;
    height: 110px;
}

.page--person .person-name {
    font-size: 60px;
}

.page--person .target-date {
    font-size: 29px;
}

.page--person .countdown-value {
    font-size: 80px;
}

.page--person .countdown-label {
    font-size: 26px;
}

.page--person .totals .countdown-value {
    font-size: 38px;
}

.back-link-row {
    text-align: center;
    margin: 26px 0 0;
}

.back-link {
    display: inline-block;
    font-family: var(--nastaliq);
    font-size: 25px;
    line-height: 1.5;
    color: var(--accent-dark);
    border-bottom: 1px solid var(--hairline);
    padding-bottom: 2px;
    transition: color var(--ease), border-color var(--ease);
}

.back-link:hover {
    color: var(--ink);
    border-bottom-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Mobile — same identity, smaller.
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .page-shell {
        width: calc(100% - 32px);
        padding-top: 34px;
    }

    .page-header {
        margin-bottom: 26px;
    }

    .title-calligraphy {
        width: min(390px, 86vw);
    }

    .title-ornament {
        max-width: 190px;
        margin-top: 10px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .person-card {
        padding: 20px 18px;
        border-radius: 16px;
    }

    .card-header {
        gap: 14px;
        margin-bottom: 18px;
    }

    .profile-image {
        width: 60px;
        height: 60px;
    }

    .person-name {
        font-size: 37px;
    }

    .target-date {
        font-size: 24px;
    }

    .countdown-grid {
        gap: 7px;
    }

    .countdown-box {
        padding: 10px 4px 9px;
        border-radius: 10px;
    }

    .countdown-value {
        font-size: 43px;
        line-height: 1.28;
    }

    .countdown-label {
        font-size: 21px;
    }

    .section-divider {
        gap: 10px;
        margin: 20px 0 13px;
    }

    .section-divider strong {
        font-size: 24px;
        gap: 9px;
    }

    .totals .countdown-box {
        padding: 8px 3px 7px;
    }

    .totals .countdown-value {
        font-size: clamp(15px, 4.8vw, 22px);
    }

    .totals .countdown-label {
        font-size: 17px;
    }

    .site-footer {
        margin-top: 40px;
        margin-bottom: 24px;
        font-size: 21px;
        gap: 10px;
    }

    /* Ornaments would crowd a small screen. */
    .corner-ornament {
        display: none;
    }

    .page--person .person-card {
        padding: 24px 18px 22px;
    }

    .page--person .card-header {
        gap: 16px;
        margin-bottom: 20px;
    }

    .page--person .profile-image {
        width: 82px;
        height: 82px;
    }

    .page--person .person-name {
        font-size: 48px;
    }

    .page--person .target-date {
        font-size: 25px;
    }

    .page--person .countdown-value {
        font-size: 58px;
    }

    .page--person .countdown-label {
        font-size: 22px;
    }

    .page--person .totals .countdown-value {
        font-size: clamp(16px, 5vw, 24px);
    }

    .back-link {
        font-size: 22px;
    }
}

/* Very narrow screens: shrink type and gaps — the four units stay on one row. */
@media (max-width: 360px) {
    .page-shell {
        width: calc(100% - 24px);
    }

    .title-calligraphy {
        width: 90vw;
    }

    .person-card {
        padding: 18px 14px;
    }

    .countdown-grid {
        gap: 6px;
    }

    .countdown-box {
        padding: 9px 2px 8px;
    }

    .countdown-value {
        font-size: 38px;
    }

    .countdown-label {
        font-size: 20px;
    }

    .section-divider strong {
        font-size: 22px;
    }

    .totals .countdown-box {
        padding: 7px 2px 6px;
    }

    .totals .countdown-value {
        font-size: clamp(12px, 4vw, 16px);
    }

    .totals .countdown-label {
        font-size: 15px;
    }

    .page--person .countdown-value {
        font-size: 45px;
    }

    .page--person .totals .countdown-value {
        font-size: clamp(12px, 4vw, 16px);
    }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    .person-card:hover {
        transform: none;
    }
}
