/* ============================================================================
   95-rtl.css - the right-to-left layer. First written for Hebrew (he).

   <html dir> is written by the server from AppLanguages.Direction, so every rule
   here hangs off [dir="rtl"] and cannot match a left-to-right page at all. That
   is the contract of this file: nothing in it may move a pixel in Russian.

   MOST OF THE MIRROR IS NOT HERE. A flex row, a grid with named areas, `gap`,
   `justify-content: space-between` and `text-align: start` all turn around on
   their own, and the simple one-sided rules in the other sheets were converted
   in place to their logical twins (margin-inline-start, padding-inline-end,
   inset-inline-start, border-inline-start, text-align: start/end), so one
   declaration serves both directions. Reach for that first when a new rule
   needs mirroring.

   WHAT LIVES HERE is what a logical property cannot say:
     1. things that must NOT turn around inside a mirrored page: clock and
        countdown digits, code-like values, the brand plates;
     2. directional glyphs, turned with a transform, never by swapping the glyph
        in markup;
     3. properties with no logical form: background-position, transform-origin,
        gradient angles, a light source painted into a background;
     4. positions that are physical on purpose in the base sheet and need a
        mirrored twin (the calendar bookmark);
     5. bidirectional text: user-written titles, names, links.

   Never mirror: the streak flame, pet and artifact art, avatars, the Pit, brand
   marks, media controls, a chart whose axis is time.

   Loaded after every component sheet and before 24-theme-dark.css, which stays
   last. This file declares geometry and direction; it has no colour of its own
   to win or lose against the dark theme.
   ============================================================================ */


/* ---- 1. digits and instruments keep their own direction ---------------------
   A clock reads hours, minutes, seconds from left to right in every language.
   The cells of both chronometers are separate flex items, so without this the
   row is laid out right to left and 10:27:45 is drawn as 45 27:10. */
[dir="rtl"] .lc-time,
[dir="rtl"] .timer,
[dir="rtl"] .egate-drums {
    direction: ltr;
}

/* The engraved TIME plate and the founder capsule (heart + ordinal) are marks on
   an instrument, not copy. The plate also centres itself with a text-indent that
   only balances its tracking when the line starts on the left. */
[dir="rtl"] .lc-plate,
[dir="rtl"] .uchip-decor {
    direction: ltr;
}

/* The deadline picker's hour and minute. The DOM order stays hour, minute (that
   is the tab order), the row is drawn hour : minute, and the "end of day" chip
   still closes the row on its far side. */
[dir="rtl"] .dtf-time > .dtf-clock:first-child { order: 3; }
[dir="rtl"] .dtf-time > .dtf-colon { order: 2; }
[dir="rtl"] .dtf-time > .dtf-colon + .dtf-clock { order: 1; }
[dir="rtl"] .dtf-time > .dtf-eod { order: 4; }

/* v0.24.0.0: the timeline is a chart whose axis is time (54-timeline.css). The hour
   gutter stays on the left and a week reads Monday to Sunday from the left, as on
   any clock or calendar grid. What a person typed inside a block still takes its own
   direction, and lines up from its own start. */
[dir="rtl"] .tl-axis,
[dir="rtl"] .tlw-grid {
    direction: ltr;
}
/* v0.27.0.0: the report's bars are days, so they are time too: Monday (or Sunday) on the
   left, the month's 1st on the left (58-period-report.css). */
[dir="rtl"] .rp-bars {
    direction: ltr;
}
[dir="rtl"] .tl-block-title,
[dir="rtl"] .tlw-head-due-title,
[dir="rtl"] .rp-left-title,
[dir="rtl"] .rp-label-name {
    unicode-bidi: plaintext;
    text-align: start;
}
/* The phone's week agenda is a list, not the axis, so it does follow the page: its "now" pointer
   stands on the right with the rows' times, and its red nose, the face's glint and the rim's run
   from violet into red all turn to face the left. */
[dir="rtl"] .tlw-agenda {
    --tl-now-flow: 270deg;
    --tl-now-tip: polygon(100% 0, 0 50%, 100% 100%);
    --tl-now-face-glow: 12% 30%;
}

/* "used / limit" is a ratio and is read like one, small number first on the left.
   Left alone the two numbers trade places around the slash ("150 / 0"). */
[dir="rtl"] .settings-ai-value {
    direction: ltr;
    unicode-bidi: isolate;
}
/* v0.27.0.0: the report's "6/7" and "64%" are a ratio and a measure; the pair stays in its own
   order and the tile keeps it on the reading side. */
[dir="rtl"] .rp-tile-num {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: right;
}
/* The mono value on a settings chip is a unit or a number ("°C", "24"): the degree
   sign leads its letter in every language. */
[dir="rtl"] .settings-chip-mono {
    direction: ltr;
    unicode-bidi: isolate;
}

/* A signed weight ("+15%") keeps its plus in front of the digits, and stays packed
   against the mark it belongs to. */
[dir="rtl"] .dsp-weight {
    direction: ltr;
    text-align: left;
}

/* Code, keys and preformatted blocks are Latin by nature. */
[dir="rtl"] code,
[dir="rtl"] kbd,
[dir="rtl"] samp {
    direction: ltr;
    unicode-bidi: isolate;
}
[dir="rtl"] pre {
    direction: ltr;
    text-align: left;
}


/* ---- 2. the light inside the two capsules -----------------------------------
   Both bezels paint a cast near their lit end: the streak clock by its flame, the
   local clock by its sun. The parts trade sides with the page, so the light has
   to follow them. These restate the base backgrounds with only the gradient's
   x position mirrored (88% <-> 12%); keep them in step with 01-topbar.css
   (.streak-clock, .streak-clock.is-frozen) and 47-local-clock.css (.local-clock).
   The broken clock has no cast and is left alone. */
[dir="rtl"] .streak-clock:not(.is-frozen):not(.is-broken) {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 40%),
        radial-gradient(130% 100% at 12% 30%, rgba(168, 85, 247, 0.28), transparent 62%),
        linear-gradient(180deg, #241F35 0%, #14121F 58%, #1A1728 100%);
}
[dir="rtl"] .streak-clock.is-frozen {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 40%),
        radial-gradient(130% 100% at 12% 30%, rgba(59, 130, 246, 0.30), transparent 62%),
        linear-gradient(180deg, #1C2740 0%, #101828 58%, #152036 100%);
}
/* Above the phone layout only: under 481px the local clock gives up its capsule
   (02-main-layout.css) and must not get a background back from here. */
@media (min-width: 481px) {
    [dir="rtl"] .local-clock {
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 40%),
            radial-gradient(130% 100% at 88% 30%, var(--lc-cast, rgba(168, 85, 247, 0.24)), transparent 62%),
            linear-gradient(180deg, #241F35 0%, #14121F 58%, #1A1728 100%);
    }
}


/* ---- 3. directional glyphs --------------------------------------------------
   "Back" points to where the reading started, which is the right. The arrows are
   text glyphs in a span of their own; they are turned, not replaced. inline-block
   because a transform does not apply to a plain inline box. */
[dir="rtl"] .page-back-arrow,
[dir="rtl"] .upgrade-back-arrow,
[dir="rtl"] .store-back-arrow,
[dir="rtl"] .store-open-arrow {
    display: inline-block;
    transform: scaleX(-1);
}

/* A Material icon that draws a direction: the rising line of "nudge progress"
   climbs toward the end of the line (Material ships trending_up auto-mirrored). */
[dir="rtl"] .progress-nudge .material-icons {
    transform: scaleX(-1);
}

/* v0.27.0.0: the report's arrows are Material chevrons (not mirrored characters), so "earlier"
   is turned to point at the right, where the reading started; its trend line climbs the same way. */
[dir="rtl"] .rp-step .material-icons,
[dir="rtl"] .rp-delta .material-icons {
    transform: scaleX(-1);
}

/* (The chevrons need nothing: U+2039 and U+203A are mirrored characters, so the
   calendar's previous and next, a task row's "open" and the notice chip's tail
   already point the right way in a right-to-left line.) */


/* ---- 4. properties with no logical form -------------------------------------- */

/* The caret of a select sits on the far side of its value. */
[dir="rtl"] .chronos-select {
    padding: 10px 12px 10px 34px;
    background-position: left 12px center;
}
[dir="rtl"] .cal-head .year {
    padding: 0 8px 0 20px;
    background-position: left 6px center;
}
@media (max-width: 720px) {
    [dir="rtl"] .card.calendar .cal-head .year {
        padding: 0 6px 0 17px;
        background-position: left 4px center;
    }
}

/* A friend row's small flame is scaled about its outer foot so it stays seated on
   the row's leading edge. */
[dir="rtl"] .fr-score .pair-flame { transform-origin: right bottom; }

/* Progress fills grow from the right; their gradients run with them. */
[dir="rtl"] .dsb-quality,
[dir="rtl"] .rp-meter-fill {
    background: linear-gradient(270deg, var(--chronos-violet), var(--chronos-lavender));
}
[dir="rtl"] .pet-evo-fill,
[dir="rtl"] .pet-level-fill {
    background: linear-gradient(270deg, #f59e0b, #fcd34d);
}


/* ---- 5. the calendar bookmark ------------------------------------------------
   Desktop: the bookmark hangs off the calendar's outer edge, the one that faces
   the task panel. 03-filter-ribbon.css already knows how to hang it on either
   side, with its picture turned to match, off one token: --arr-cal-side, 0 when
   the calendar is on the left and 1 when it is on the right. A right-to-left row
   puts the calendar on the other side of every arrangement, so the token is
   inverted here and the position, the hover slide and the drawing follow from the
   base rules untouched. */
@media (min-width: 981px) {
    [dir="rtl"] .ribbon-filter {
        --arr-cal-side: calc(1 - clamp(0, calc(var(--arr-main-calendar, 0) - var(--arr-main-tasks, 1)), 1));
    }
    /* Before the card is revealed the bookmark waits tucked behind it, on its own side. */
    html[dir="rtl"].cm-motion .card.calendar[data-reveal]:not(.cm-in) ~ .ribbon-filter {
        transform: translateX(26px);
    }
}
/* Phone: it stands on the card's top edge in the far corner, which the month
   switcher leaves free (its padding-inline-end in 02-main-layout.css). */
@media (max-width: 720px) {
    [dir="rtl"] .ribbon-filter {
        right: auto;
        left: 14px;
    }
}

/* The pet's speech bubble in the two-row band: anchored to the pet, which is now
   at the right edge, and growing away from it. */
@media (min-width: 721px) and (max-width: 980px) {
    [dir="rtl"] .pet-bubble {
        left: auto;
        right: 0;
    }
    [dir="rtl"] .pet-bubble::before {
        left: auto;
        right: 22px;
        margin-left: 0;
        margin-right: -6px;
    }
}


/* ---- 6. bidirectional text ---------------------------------------------------
   What a person typed keeps the direction of what they typed. A task called
   "Ship v2.1 (beta)." inside a Hebrew board is an English sentence: without this
   its full stop and its bracket jump to the wrong end. plaintext takes each
   line's direction from its first strong letter, the way dir="auto" does.

   The ALIGNMENT stays with the page: pinned to the right, so a Latin title still
   starts beside its checkbox instead of flying to the far edge of the card, and a
   Latin description stays under the Hebrew labels around it. Only the order of
   the characters follows the text. */
[dir="rtl"] .task-title,
[dir="rtl"] .task-supporting,
[dir="rtl"] .main-task-title,
[dir="rtl"] .main-task-desc,
[dir="rtl"] .subtask-title,
[dir="rtl"] .tw-title,
[dir="rtl"] .detail-desc,
[dir="rtl"] .markdown-body p,
[dir="rtl"] .markdown-body li,
[dir="rtl"] .drafts-entry-title,
[dir="rtl"] .almanac-entry-title,
[dir="rtl"] .uchip-name,
[dir="rtl"] .fr-refseat-name,
[dir="rtl"] .pair-modal-side-name,
[dir="rtl"] .share-pick-name,
[dir="rtl"] .tl-due-title,
[dir="rtl"] .tlw-arow-title {
    unicode-bidi: plaintext;
    text-align: right;
}

/* Fields that only ever hold Latin: an address, a password, a login, a link.
   Typed left to right, and resting against the right edge where the eye starts. */
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="url"],
[dir="rtl"] input[autocomplete="username"],
[dir="rtl"] .referral-link-input {
    direction: ltr;
    text-align: right;
}
/* A friend's name can be in any script: let the field follow what is typed. */
[dir="rtl"] .friends-input[name="username"] {
    unicode-bidi: plaintext;
    text-align: right;
}


/* ---- 7. the store on a phone -------------------------------------------------
   .store-page is a flex item with auto margins and no definite width, so it sizes
   to its widest child, and the filter rows (nowrap, meant to scroll inside) made
   the page 590px wide on a 375px screen. In a right-to-left page that overflow
   opens to the LEFT of the first screen, where nothing says it is there. Capping
   the page at its container hands the scroll back to the rows.
   The left-to-right page had the same overflow, so the cap now lives on the base
   rule in 25-store.css and nothing is needed here. 38-legal.css documents the cause. */
