/* Public home page: a notebook, both sides of the book, and one day in the shop. Colors come from tokens.css. */
:root {
    --bottle: #0A3A31;
    --deep: #072A23;
    --paper-edge: #DDD8CC;
    --rule: #C9D8E4;
    --ledger-ink: #1C3F75;
    --hand: 'Caveat', cursive;
    --hand-size: 1.65rem;
    --screen-height: 270px;
    --tight: -0.035em;
    --tighter: -0.04em;
    --tightish: -0.025em;
}

/* Tightened tracking breaks the joins in Arabic script, so RTL languages keep normal spacing. */
:root:lang(ku), :root:lang(ar) {
    --hand: 'Aref Ruqaa', 'IBM Plex Sans Arabic', serif;
    --hand-size: 1.6rem;
    --tight: 0;
    --tighter: 0;
    --tightish: 0;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bottle);
    color: var(--dm-paper);
    font-family: var(--dm-font);
    line-height: 1.55;
}

button, input {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

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

:focus-visible {
    outline: 3px solid var(--dm-gold);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    inset-block-start: -4rem;
    inset-inline-start: 1rem;
    z-index: 10;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: var(--dm-gold);
    color: var(--dm-ink);
    font-weight: 700;
}

.skip-link:focus {
    inset-block-start: 1rem;
}

/* Header */
.nav {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    max-width: 1228px;
    margin: 0 auto;
    padding: 1.2rem 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 800;
    font-size: 1.15rem;
}

.logo img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
}

.links {
    display: flex;
    gap: 1.2rem;
    margin-inline-start: auto;
    font-size: 0.95rem;
    overflow: visible;
}

.links a.what:hover,
.nav-submenu-trigger.what:hover {
    color: var(--dm-gold);
}

.nav-submenu {
    position: relative;
}

.nav-submenu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    cursor: pointer;
    white-space: nowrap;
}

.nav-submenu-trigger::-webkit-details-marker {
    display: none;
}

.nav-submenu-trigger::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-inline-end: 2px solid currentColor;
    border-block-end: 2px solid currentColor;
    transform: rotate(45deg);
    margin-block-start: -0.15rem;
    opacity: 0.75;
    transition: transform 0.15s ease;
}

.nav-submenu[open] .nav-submenu-trigger {
    color: var(--dm-gold);
}

.nav-submenu[open] .nav-submenu-trigger::after {
    transform: rotate(-135deg);
    margin-block-start: 0.1rem;
}

.nav-submenu-panel {
    position: absolute;
    z-index: 200;
    top: calc(100% + 0.45rem);
    inset-inline-end: 0;
    min-width: 11rem;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    background: var(--dm-surface);
    color: var(--dm-ink);
    border: 1px solid var(--dm-border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(23, 33, 43, 0.12);
}

.nav-submenu-panel a {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    color: var(--dm-ink);
    font-weight: 700;
    font-size: 0.92rem;
    white-space: nowrap;
}

.nav-submenu-panel a:hover {
    background: var(--dm-payment-container);
    color: var(--dm-green);
}

.dm-lang {
    display: flex;
    gap: 0.2rem;
}

.dm-lang-btn {
    padding: 0.25rem 0.55rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--dm-paper);
    font-size: 0.9rem;
    white-space: nowrap;
}

.dm-lang-btn:hover {
    color: var(--dm-gold);
}

.dm-lang-btn[aria-pressed="true"] {
    background: rgba(245, 243, 238, 0.14);
}

.signin {
    display: inline-block;
    padding: 0.5rem 1.05rem;
    border-radius: 6px;
    background: var(--dm-gold);
    color: var(--dm-ink);
    font-weight: 700;
    white-space: nowrap;
}

/* The notebook */
.hero {
    padding: 0 1.5rem 4.5rem;
}

.book {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1180px;
    margin: 1rem auto 0;
    border-radius: 6px 6px 10px 10px;
    background: var(--dm-paper);
    color: var(--dm-ink);
    box-shadow: 0 2px 0 var(--paper-edge), 0 5px 0 #CFC9BA, 0 8px 0 var(--paper-edge), 0 34px 60px rgba(0, 0, 0, 0.4);
}

/* The fold sits at the physical middle of the book in every language. */
.book::after {
    content: "";
    position: absolute;
    inset-block: 0;
    left: 50%;
    width: 40px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(23, 33, 43, 0.13) 48%, rgba(23, 33, 43, 0.2) 50%, rgba(23, 33, 43, 0.13) 52%, transparent);
    pointer-events: none;
}

.ribbon {
    position: absolute;
    inset-block-start: -10px;
    inset-inline-end: calc(50% + 34px);
    z-index: 2;
    width: 34px;
    height: 120px;
    background: var(--dm-gold);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%);
}

.page {
    min-width: 0;
    padding: 3.2rem 3.4rem 3rem;
}

.page h1 {
    margin: 0 0 1rem;
    color: var(--dm-green);
    font-size: clamp(2.5rem, 4.7vw, 4.3rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: var(--tight);
}

:root:lang(ku) .page h1, :root:lang(ar) .page h1 {
    padding-inline-end: 2.5rem;
    margin-bottom: 1.3rem;
    font-size: clamp(2rem, 3.2vw, 3rem);
    line-height: 1.25;
}

.lead {
    max-width: 32rem;
    margin: 0;
    color: #333F4A;
    font-size: 1.12rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1.5rem;
}

.ink-btn, .line-btn {
    display: inline-block;
    padding: 0.8rem 1.25rem;
    border: 2px solid var(--dm-green);
    border-radius: 6px;
    font-weight: 700;
    text-align: center;
}

.ink-btn {
    background: var(--dm-green);
    color: #fff;
}

.line-btn {
    color: var(--dm-green);
}

.stores-block {
    margin-top: 1.6rem;
}

.stores-block--contact {
    margin-top: 1.25rem;
}

.stores-title {
    margin: 0 0 0.5rem;
    font-size: 0.92rem;
    font-weight: 600;
}

.stores {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Store badge: follows page direction; western store names stay LTR on their own. Not a link until the apps are published. */
.store {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 158px;
    min-height: 3.15rem;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    background: var(--dm-ink);
    color: #fff;
    cursor: default;
    text-align: start;
    box-sizing: border-box;
}

.store svg {
    flex: none;
}

.store small {
    display: block;
    color: var(--dm-gold);
    font-size: 0.72rem;
    line-height: 1.3;
}

.store b {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
}

.stores > li > .store {
    height: 100%;
}

a.store.store--contact {
    cursor: pointer;
    background: var(--dm-green);
}

a.store.store--contact:hover {
    filter: brightness(1.08);
    color: #fff;
}

a.store.store--contact span:only-child {
    display: flex;
    align-items: center;
}

.dayend a.store.store--contact {
    background: var(--dm-paper);
    color: var(--dm-ink);
    border: 2px solid var(--dm-green);
}

.dayend a.store.store--contact:hover {
    background: rgba(10, 58, 49, 0.06);
    color: var(--dm-ink);
    filter: none;
}

.dayend a.store.store--contact small {
    color: var(--dm-green);
}

.dayend .stores-block {
    flex-basis: 100%;
    margin-top: 0;
}

.dayend .store {
    background: var(--dm-paper);
    color: var(--dm-ink);
}

.dayend .store small {
    color: var(--dm-green);
}

.ledger {
    min-height: 430px;
    background-image: repeating-linear-gradient(transparent 0 43px, var(--rule) 43px 44px);
    background-position: 0 74px;
}

.ledger h2 {
    height: 58px;
    margin: 0 0 16px;
    color: var(--dm-muted);
    font-size: 1.05rem;
    font-weight: 600;
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    height: 44px;
    color: var(--ledger-ink);
    font-family: var(--hand);
    font-size: var(--hand-size);
    font-weight: 500;
}

.row span:last-child {
    flex: none;
    white-space: nowrap;
}

.row .plus {
    color: var(--dm-debt);
}

.row .minus {
    color: var(--dm-green);
}

.row.new {
    animation: write 0.5s ease-out;
}

@keyframes write {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
}

/* Handwriting runs from the right in Kurdish and Arabic. */
[dir="rtl"] .row.new {
    animation-name: write-rtl;
}

@keyframes write-rtl {
    from { clip-path: inset(0 0 0 100%); }
    to { clip-path: inset(0 0 0 0); }
}

.total {
    display: flex;
    justify-content: space-between;
    margin-top: 0.7rem;
    padding-block: 0.35rem;
    border-block: 3px double var(--dm-ink);
    font-size: 1.15rem;
    font-weight: 800;
}

.write {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1.2rem;
}

.write input {
    flex: 1 1 120px;
    min-width: 0;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--paper-edge);
    border-radius: 6px;
    background: #fff;
    color: var(--dm-ink);
}

.write button {
    padding: 0.6rem 0.85rem;
    border: 0;
    border-radius: 6px;
    color: #fff;
    font-weight: 700;
    text-align: center;
}

.write .d {
    background: var(--dm-debt);
}

.write .p {
    background: var(--dm-green);
}

.hint {
    min-height: 1.3em;
    margin: 0.5rem 0 0;
    color: var(--dm-muted);
    font-size: 0.85rem;
}

/* Both sides of the book */
.both {
    scroll-margin-top: 1rem;
    padding: 0 1.5rem 4.5rem;
}

.sides-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: 1180px;
    margin: 0 auto;
    padding-bottom: 2.2rem;
}

.sides-head h2 {
    max-width: 15ch;
    margin: 0;
    font-size: clamp(2.5rem, 4.7vw, 4.3rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: var(--tight);
}

:root:lang(ku) .sides-head h2, :root:lang(ar) .sides-head h2 {
    max-width: none;
    font-size: clamp(2rem, 3.2vw, 3rem);
    line-height: 1.2;
}

:root:lang(ku) .dayhead h2, :root:lang(ar) .dayhead h2 {
    line-height: 1.2;
}

.mode {
    display: flex;
    overflow: hidden;
    border: 2px solid var(--dm-paper);
    border-radius: 8px;
}

.mode button {
    padding: 0.65rem 1rem;
    border: 0;
    background: transparent;
    font-weight: 600;
    text-align: center;
}

.mode button[aria-pressed="true"] {
    background: var(--dm-paper);
    color: var(--dm-ink);
}

.sides {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    max-width: 1180px;
    min-height: 500px;
    margin-inline: auto;
    border-radius: 6px 6px 10px 10px;
    box-shadow: 0 34px 60px rgba(0, 0, 0, 0.4);
    transition: grid-template-columns 0.35s ease;
}

.sides.lend {
    grid-template-columns: 1fr 0fr;
}

.sides.borrow {
    grid-template-columns: 0fr 1fr;
}

.side {
    overflow: hidden;
    min-width: 0;
}

/* Half the block's width, so text does not reflow while one side slides shut. */
.side > div {
    min-width: calc((min(100vw, 1228px) - 3rem) / 2);
    padding: 2.8rem clamp(1.5rem, 3.5vw, 3rem) 3rem;
}

.they {
    background: var(--dm-gold);
    color: var(--dm-ink);
}

.you {
    background: var(--dm-green);
    color: #fff;
}

.side h3 {
    margin: 0 0 1.5rem;
    font-size: clamp(2.3rem, 4.6vw, 4.2rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
}

:root:lang(ku) .side h3, :root:lang(ar) .side h3 {
    font-size: clamp(2rem, 3.6vw, 3.2rem);
    line-height: 1.25;
    letter-spacing: 0;
}

.who {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.82rem 0;
    border-top: 2px solid currentColor;
    font-size: 1.1rem;
    font-weight: 600;
}

.who small {
    display: block;
    font-size: 0.83rem;
    font-weight: 500;
    opacity: 0.8;
}

.who.bad b {
    align-self: flex-start;
    padding: 0 0.4rem;
    background: var(--dm-ink);
    color: var(--dm-gold);
    font-weight: 700;
}

.lower {
    background: var(--deep);
}

.jobs {
    max-width: 1228px;
    margin: 0 auto;
    padding: 4rem 1.5rem 4.5rem;
}

.job {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    align-items: baseline;
    gap: 2rem;
    padding: 1.5rem 0;
    border-top: 1px solid rgba(245, 243, 238, 0.25);
}

.job h3 {
    margin: 0;
    color: var(--dm-gold);
    font-size: clamp(1.45rem, 2.7vw, 2.25rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: var(--tightish);
}

.job p {
    max-width: 38rem;
    margin: 0;
    color: #DBE7E3;
    font-size: 1.05rem;
}

/* One day */
.day {
    padding-bottom: 4.5rem;
}

.dayhead {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    align-items: end;
    gap: 2rem;
    max-width: 1228px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.dayhead h2 {
    margin: 0;
    font-size: clamp(2.5rem, 4.7vw, 4.3rem);
    font-weight: 700;
    line-height: 0.98;
    letter-spacing: var(--tighter);
}

:root:lang(ku) .dayhead h2, :root:lang(ar) .dayhead h2 {
    font-size: clamp(2rem, 3.2vw, 3rem);
}

.dayhead p {
    margin: 0 0 0.4rem;
    color: #CFE0DA;
    font-size: 1.12rem;
}

.sun {
    max-width: 1180px;
    height: 6px;
    margin: 0 auto;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--dm-mint), var(--dm-gold) 55%, var(--dm-debt));
}

[dir="rtl"] .sun {
    background: linear-gradient(270deg, var(--dm-mint), var(--dm-gold) 55%, var(--dm-debt));
}

.stop {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 2.2rem;
    max-width: 1228px;
    margin: 0 auto;
    padding: 3.2rem 1.5rem;
    border-bottom: 1px solid rgba(245, 243, 238, 0.14);
}

.time {
    color: var(--dm-gold);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.stop h3 {
    margin: 0 0 0.6rem;
    font-size: clamp(1.55rem, 2.7vw, 2.3rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: var(--tightish);
}

.stop p {
    max-width: 30rem;
    margin: 0;
    color: #CFE0DA;
    font-size: 1.05rem;
}

/* Every screen in the day is the same size; rows stretch to fill it. */
.screen {
    display: flex;
    flex-direction: column;
    justify-self: center;
    width: min(100%, 380px);
    min-height: var(--screen-height);
    padding: 0.9rem;
    border: 7px solid #0F1C18;
    border-radius: 22px;
    background: var(--dm-paper);
    color: var(--dm-ink);
    font-size: 0.92rem;
}

.scrtop {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.7rem;
    color: var(--dm-muted);
    font-size: 0.78rem;
}

.off {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--dm-overdue-container);
    color: var(--dm-overdue);
}

.synced {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--dm-payment-container);
    color: var(--dm-green);
}

.li {
    display: flex;
    flex: 1;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    border-top: 1px solid #E6E1D6;
}

.li b {
    font-weight: 700;
}

.wa {
    flex: 1;
    padding: 0.65rem 0.8rem;
    border-radius: 10px 10px 2px 10px;
    background: #D9FDD3;
}

[dir="rtl"] .wa {
    border-radius: 10px 10px 10px 2px;
}

.send {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.send span {
    padding: 0.28rem 0.6rem;
    border-radius: 6px;
    background: #EBE7DD;
    font-size: 0.82rem;
}

.dayend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: 1228px;
    margin: 0 auto;
    padding: 3rem 1.5rem 0;
}

.dayend h2 {
    margin: 0;
    font-size: clamp(1.8rem, 3.4vw, 3rem);
    font-weight: 700;
    letter-spacing: var(--tightish);
}

/* Below this the amount box gets its own line, so its prompt is never cut off. */
@media (max-width: 1100px) {
    .write input {
        flex-basis: 100%;
    }

    .write button {
        flex: 1;
    }
}

@media (max-width: 860px) {
    .nav {
        flex-wrap: wrap;
        gap: 0.6rem;
        padding-inline: 0.75rem;
    }

    .links {
        display: none;
    }

    .logo {
        font-size: 1rem;
    }

    .logo img {
        width: 28px;
        height: 28px;
    }

    .signin {
        padding-inline: 0.8rem;
    }

    .nav .signin {
        margin-inline-start: auto;
    }

    .dm-lang {
        order: 3;
        justify-content: center;
        width: 100%;
    }

    .hero, .both {
        padding-inline: 0.75rem;
    }

    .book {
        grid-template-columns: 1fr;
    }

    .book::after {
        display: none;
    }

    .page {
        padding: 2.2rem 1.4rem;
    }

    .ribbon {
        inset-inline-end: 1rem;
        width: 24px;
        height: 42px;
    }

    .ledger {
        min-height: 0;
        padding-bottom: 88px;
    }

    .mode {
        width: 100%;
    }

    .mode button {
        flex: 1;
        padding-inline: 0.4rem;
        font-size: 0.88rem;
        line-height: 1.25;
    }

    .sides {
        grid-template-columns: 1fr !important;
        min-height: 0;
    }

    .sides.lend .you, .sides.borrow .they {
        display: none;
    }

    .side > div {
        min-width: 0;
    }

    .job {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .dayhead {
        grid-template-columns: 1fr;
    }

    .stop {
        grid-template-columns: 1fr;
        gap: 1.1rem;
        padding-block: 2.4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .row.new {
        animation: none;
    }

    .sides {
        transition: none;
    }
}
