/*
 * HOME-02 - the homepage, and only the homepage.
 *
 * Linked from `content/home_page.html` alone and scoped to its `body.home-ui`, the same
 * pattern the dashboard and the profile use, so nothing here can reach another page. The
 * shared pieces it builds on - the hero, the game tile, the content card, the rail - keep
 * their rules in `platform.css`; this file only arranges them for this page.
 *
 * Brand-free like the core sheet: every colour is a token.
 */

/* -- the column ------------------------------------------------------------------------ */

/* The page sits in the same frame as the header and the footer (`--chrome-width`), so the
   games and the editorial cards line up with the lockup above them and the footer below. */
.home-ui > .page {
  max-width: var(--chrome-width);
  padding-bottom: 0;
}

/* One gap between the last section and the footer, not the page's padding stacked on the
   footer's own margin - that was close to a hundred pixels of empty ground on a phone. */
.home-ui .site-footer {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
}

/* -- the hero ---------------------------------------------------------------------------- */

/* One line and two actions, centred over the globe. With the badge and the paragraph gone
   the fold no longer needs room for them: the copy is centred in the picture rather than
   parked at its bottom edge, and the picture is a little shorter so what follows is in
   reach of the first screen. */
.home-ui .hero {
  align-items: center;
  min-height: clamp(26rem, 66vh, 38rem);
}

.home-ui .hero__inner {
  padding: clamp(3rem, 9vh, 6rem) var(--chrome-gutter) clamp(2.5rem, 7vh, 4.5rem);
}

/* The headline is set to read as two balanced lines on any screen wide enough to hold it
   on one: the measure is in `em`, so it scales with the type rather than with the
   viewport, and `balance` chooses the break. The Persian fallback breaks after «بازیت»;
   «از این‌جا» is held together by the template's no-break space. Real ExtraBold from
   the self-hosted face - nothing here asks the browser to fake a weight. */
.home-ui .home-hero__title {
  max-inline-size: 9.5em;
  margin: 0 auto 1.6rem;
  font-size: clamp(2.15rem, 1.15rem + 3.6vw, 4rem);
  font-weight: 800;
  line-height: 1.42;
  letter-spacing: 0;
  text-wrap: balance;
}

/* Latin words are shorter per character than the Persian ones the measure above was set
   for, so the same two lines need a wider column in English. */
[dir="ltr"] .home-ui .home-hero__title {
  max-inline-size: 13em;
}

/* Two equal, generous actions under the headline. */
.home-ui .hero__actions {
  gap: 0.85rem;
}

.home-ui .hero__actions .btn {
  min-height: 3.25rem;
  min-inline-size: 11.5rem;
  padding-inline: 1.9rem;
  font-size: 1.05rem;
  font-weight: 700;
}

/* -- the feature strip ------------------------------------------------------------------- */

/* A thin glass rail laid over the foot of the hero, so it reads as the picture's own
   caption line rather than a new section: four facts in one row on a desktop, two by two
   on a phone. Icons are emerald with a cyan second stroke - the brand's two neon notes;
   a brand without the second colour simply gets its accent twice. */
.home-strip {
  position: relative;
  z-index: 2;
  margin-top: calc(-1 * clamp(2.25rem, 4vw, 3rem));
}

.home-strip__list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 0.55rem;
  list-style: none;
  border: 1px solid var(--accent-edge, var(--line));
  border-radius: var(--radius-lg);
  background: var(--surface-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
}

.home-strip__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-inline-size: 0;
  padding: 0.45rem 0.9rem;
}

.home-strip__item + .home-strip__item {
  border-inline-start: 1px solid var(--line);
}

.home-strip__icon,
.home-steps__icon {
  display: grid;
  flex: none;
  place-items: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  border: 1px solid var(--accent-edge, var(--line));
  border-radius: var(--radius);
  color: var(--accent);
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent) 16%, transparent),
      color-mix(in srgb, var(--home-feature-cyan, var(--accent)) 12%, transparent));
  box-shadow: var(--glow-soft);
}

.home-strip__icon svg,
.home-steps__icon svg {
  inline-size: 1.35rem;
  block-size: 1.35rem;
}

.home-strip__icon .home-icon__alt,
.home-steps__icon .home-icon__alt {
  stroke: var(--home-feature-cyan, var(--accent));
}

.home-strip__text {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  line-height: 1.5;
}

.home-strip__title {
  font-weight: 800;
  font-size: 0.98rem;
  color: var(--ink);
}

.home-strip__sub {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* Two by two below a tablet: every fact keeps its icon and both of its words. */
@media (max-width: 899px) {
  .home-strip__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.35rem;
  }

  .home-strip__item {
    padding: 0.55rem 0.6rem;
    gap: 0.6rem;
  }

  .home-strip__item + .home-strip__item {
    border-inline-start: 0;
  }

  .home-strip__item:nth-child(even) {
    border-inline-start: 1px solid var(--line);
  }

  .home-strip__item:nth-child(n + 3) {
    border-block-start: 1px solid var(--line);
  }
}

/* The narrowest phones: two columns would wrap every title and sublabel onto two lines,
   so the facts become four short rows, each fact's title and sublabel on one line. */
@media (max-width: 400px) {
  .home-strip__list {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-strip__item {
    padding: 0.4rem 0.55rem;
  }

  .home-strip__item:nth-child(even) {
    border-inline-start: 0;
  }

  .home-strip__item + .home-strip__item {
    border-block-start: 1px solid var(--line);
  }

  .home-strip__icon {
    inline-size: 2rem;
    block-size: 2rem;
  }

  .home-strip__icon svg {
    inline-size: 1.1rem;
    block-size: 1.1rem;
  }

  .home-strip__text {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.5rem;
  }

  .home-strip__title {
    font-size: 0.9rem;
  }

  .home-strip__sub {
    font-size: 0.78rem;
  }
}

/* -- how it works ------------------------------------------------------------------------ */

/* Four compact steps in a row, joined by a chevron that points the way the page reads. On
   a phone they become a numbered list with a rail down the start edge. */
.home-steps__list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The stronger hairline and the theme's own soft shadow lift each card off the page: on
   the light page a white card on a near-white ground measured 1.08:1 with a 1.19:1 border,
   which read as one flat sheet. */
.home-steps__step {
  position: relative;
  min-inline-size: 0;
  padding: 1rem 1.1rem 1.05rem;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.home-steps__step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: -1.05rem;
  inline-size: 0.6rem;
  block-size: 0.6rem;
  border-top: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  transform: translateY(-50%) rotate(45deg);
  opacity: 0.85;
}

/* Physical borders on purpose: the chevron is a shape, and a logical border would flip
   with the direction while the rotation did not. The next step is to the left in Persian. */
[dir="rtl"] .home-steps__step:not(:last-child)::after {
  transform: translateY(-50%) rotate(-135deg);
}

.home-steps__marker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

/* Filled in the accent rather than outlined: a 1.2px outline left the Persian zero - a
   dot - as a faint ring, about 1.2:1 against the card. */
.home-steps__number {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.home-steps__title {
  margin: 0 0 0.3rem;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.6;
}

/* One step larger and a shade nearer the ink than secondary text, so the one sentence
   each step has is easy to read at a glance; the card height barely changes. */
.home-steps__text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.8;
  color: color-mix(in srgb, var(--ink) 72%, var(--ink-soft));
}

@media (max-width: 999px) {
  .home-steps__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
  }

  .home-steps__step:not(:last-child)::after {
    display: none;
  }
}

/* A phone reads the steps as a list: number and icon on the start edge, the words beside
   them, and a thin rail joining one step to the next. */
@media (max-width: 639px) {
  .home-steps__list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.7rem;
  }

  .home-steps__step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 0.85rem;
    padding: 0.8rem 0.9rem;
  }

  .home-steps__marker {
    grid-row: 1 / span 2;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.45rem;
    margin: 0;
  }

  .home-steps__number {
    font-size: 1.25rem;
  }

  .home-steps__icon {
    inline-size: 2.2rem;
    block-size: 2.2rem;
  }

  .home-steps__title {
    margin-bottom: 0.15rem;
    font-size: 0.98rem;
  }

  .home-steps__text {
    font-size: 0.9rem;
    line-height: 1.75;
  }

  .home-steps__step:not(:last-child)::after {
    display: block;
    inset-block: auto -0.75rem;
    inset-inline: 2.05rem auto;
    inline-size: 2px;
    block-size: 0.8rem;
    border: 0;
    background: var(--accent-edge, var(--line));
    transform: none;
    opacity: 1;
  }

  [dir="rtl"] .home-steps__step:not(:last-child)::after {
    transform: none;
  }
}

/* -- sections ---------------------------------------------------------------------------- */

/* One rhythm for every section after the hero: a short factual heading with its "see all"
   link on the same line, then the content. No eyebrow, no sentence under the heading. */
.home-section {
  margin-block: clamp(2.25rem, 4.5vw, 3.75rem) 0;
}

/* The first section follows the picture closely: the hero already ends in a fade to the
   page ground, so a full section gap after it reads as an empty band. */
.home-section:first-child {
  margin-block-start: clamp(1.25rem, 2.5vw, 2rem);
}

.home-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}

.home-section__title {
  margin: 0;
  font-size: clamp(1.3rem, 1.05rem + 0.9vw, 1.7rem);
  font-weight: 800;
  line-height: 1.5;
}

.home-section__more {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding-inline: 0.25rem;
  font-weight: 600;
  color: var(--accent);
}

.home-section__more:hover {
  text-decoration: underline;
}

.home-section__more:focus-visible {
  outline: 3px solid var(--ring, var(--accent));
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.home-section__more svg {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  flex: none;
}

/* The arrow points the way the line reads. */
[dir="rtl"] .home-section__more svg {
  transform: scaleX(-1);
}

/* -- supported games --------------------------------------------------------------------- */

/* The rail's own rules were written for a padded panel; here it sits on the page column.
   On a phone it bleeds to the screen edges so the next card is cut by the glass, which is
   what tells a reader the row scrolls. */
.home-games .featured-rail {
  margin-inline: calc(-1 * var(--chrome-gutter));
  padding: 0.25rem var(--chrome-gutter) 0.75rem;
}

@media (min-width: 720px) {
  .home-games .featured-rail {
    margin-inline: 0;
    padding-inline: 0;
  }
}

/* -- editorial cards --------------------------------------------------------------------- */

/* Three across on a desktop, two on a tablet, one on a phone: a fixed count rather than
   `auto-fill`, so three cards always fill the row they are given instead of leaving a
   gap where a fourth would go. HOME-EDITORIAL-ORDER-01 PR2: the Grid presentation is this
   same grid with up to six cards - two full rows of three on a desktop, three of two on a
   tablet - so Cards and Grid can never drift apart. */
.home-editorial__grid {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 640px) {
  .home-editorial__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1000px) {
  .home-editorial__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* A summary is a teaser on the homepage, not the article: three lines at most. */
.home-editorial .content-card__summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

/* On a phone a card is a row - a framed square of the picture beside the words - so three
   cards are one screen of reading rather than three screens of picture. The square is
   inset in the card with its own corner, like a thumbnail, rather than a strip cut off at
   the card's edge, and the cards sit a little closer so a section reads as one list.
   Cards and Grid only: a Slider keeps the full card, which is what a sideways row is for. */
@media (max-width: 639px) {
  .home-editorial__grid {
    gap: 0.7rem;
  }

  .home-editorial__grid .content-card {
    display: grid;
    grid-template-columns: 5.25rem minmax(0, 1fr);
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem;
  }

  .home-editorial__grid .content-card__media {
    aspect-ratio: 1;
    border-radius: var(--radius);
  }

  .home-editorial__grid .content-card__body {
    gap: 0.25rem;
    padding: 0;
    border-block-start: 0;
  }

  .home-editorial__grid .content-card__title {
    font-size: 0.98rem;
    line-height: 1.6;
  }

  .home-editorial__grid .content-card__summary {
    font-size: 0.85rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
}

/* -- editorial slider (HOME-EDITORIAL-ORDER-01 PR2) ------------------------------------------- */

/* One row of full editorial cards that scrolls inside itself, never the page. It works with
   no script: a finger, a trackpad, the keyboard (the row is a focusable, named region) and the
   thin scrollbar left visible on purpose all move it. Nothing here names left or right - the
   row starts where the language starts and the snap points are logical. */
.home-editorial__rail {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  padding-block: 0.25rem 0.85rem;
}

.home-editorial__rail:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
}

/* About three and a quarter cards on a desktop, two and a bit on a tablet and most of one on
   a phone: the next card is always cut by the edge, which is what says the row goes on. */
.home-editorial__track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 3 * 1.1rem) / 3.25);
  gap: 1.1rem;
}

.home-editorial__track > .content-grid__item {
  scroll-snap-align: start;
}

.home-editorial__tools {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
}

/* The buttons stay hidden until `rail.js` runs (`.js-rail`), and it hides them again while
   every card fits. At an end the button is `aria-disabled`, never removed and never
   `disabled`, so it keeps keyboard focus. */
.home-editorial .rail__controls[hidden] {
  display: none;
}

.home-editorial .rail__control[aria-disabled="true"] {
  opacity: 0.35;
  cursor: default;
}

.home-editorial .rail__control[aria-disabled="true"]:hover {
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

@media (max-width: 999px) {
  .home-editorial__track {
    grid-auto-columns: calc((100% - 2 * 1.1rem) / 2.25);
  }
}

/* On a phone the row bleeds to the screen edges, as the supported games row does, so the
   next card is cut by the glass; the first card still lines up with the page column. */
@media (max-width: 639px) {
  .home-editorial__rail {
    margin-inline: calc(-1 * var(--chrome-gutter));
    padding-inline: var(--chrome-gutter);
    scroll-padding-inline: var(--chrome-gutter);
  }

  .home-editorial__track {
    grid-auto-columns: 82%;
    gap: 0.85rem;
  }
}

/* -- phones ------------------------------------------------------------------------------ */

@media (max-width: 640px) {
  .home-ui .hero {
    min-height: clamp(23rem, 60vh, 28rem);
  }

  .home-ui .home-hero__title {
    margin-bottom: 1.25rem;
    line-height: 1.45;
  }

  /* Full-width actions, one per line, rather than two that wrap unevenly. */
  .home-ui .hero__actions .btn {
    flex: 1 1 100%;
    min-inline-size: 0;
  }
}
