/*
 * Together since 1966 — page styles (page-togethersince1966.php).
 * Plain CSS on purpose: no build step.
 * Font: Montserrat throughout (Google Fonts, 400/700/800, enqueued by the template); Chinese
 * falls back to the site's CJK fonts, as in screen.css.
 * Figma: desktop web_option1 273:3 (1440 wide), mobile mob_option1 273:230 (376 wide).
 * Breakpoints follow the site's: mobile < 768px, 2 card columns from 768px, 3 from 992px.
 */

.ts1966 {
  font-family: "Montserrat", "PingFang HK", "Microsoft JhengHei", 华文黑体, SimHei, 黑体, sans-serif;
  font-weight: 400;
  background: #fffff1;
  overflow-x: clip; /* crops the mobile illustration's bleed */
}

/* ---------- Key visual ---------- */

/* The three pieces keep their Figma positions, scaled with the width
   (desktop frame 1440 × 722 below the site header). */
.ts1966__hero-inner {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  aspect-ratio: 1440 / 722;
}

.ts1966__hero img {
  display: block;
  height: auto;
}

.ts1966__hero-title {
  position: absolute;
  left: 2.5%;
  top: 11.77%;
  width: 30.63%;
  margin: 0;
  z-index: 1; /* the illustration's (opaque, #fffff1-backed) box overlaps the title's right edge */
}

.ts1966__hero-title img {
  width: 100%;
}

/* The title SVG layered five times, each copy cropped to one line (see the template). The first
   is in the flow and gives the title its height; the others sit on top of it. */
.ts1966__hero-title-band {
  clip-path: inset(var(--from) 0 calc(100% - var(--to)) 0);
}

.ts1966__hero-title-band + .ts1966__hero-title-band {
  position: absolute;
  top: 0;
  left: 0;
}

/* Hidden until page.js brings them in on load (ts1966-js is set inline at the top of the page;
   page.js removes it if GSAP didn't load). */
.ts1966-js .ts1966__hero-illustration,
.ts1966-js .ts1966__hero-title-band,
.ts1966-js .ts1966__hero-since {
  visibility: hidden;
}

.ts1966__hero-illustration {
  position: absolute;
  left: 32.71%;
  top: 9.28%;
  width: 63.19%;
}

.ts1966__hero-since {
  position: absolute;
  left: 72.57%;
  top: 86.84%;
  width: 23.3%;
}

/* ---------- Memories: the text, then the photos like an album ----------

   The text scrolls with the page. Below it, on desktop, the photos are placed freely on a
   1440px-max track, at the positions of the Figma frame "Photo album — desktop" (356:2):
   left, top and width as percentages of the track (--dx/--dy/--dw and --dratio from the
   template), so the whole collage scales with the screen. On mobile they run down one zigzag
   column, each photo 60–80% wide (--mx/--mw), with fixed gaps. A vertical rule runs down the
   centre from the top of the section, broken by the text, to the bottom, behind the photos.
   page.js fades the text in line by line and each photo up as it comes into view. */

.ts1966__memories {
  --ts1966-pad-top: 100px;        /* above the text */
  --ts1966-rule-gap-top: 22px;    /* between the rule and the text, above */
  --ts1966-rule-gap-bottom: 9px;  /* and below */
  padding-top: var(--ts1966-pad-top);
  background: #f1f1de;
}

.ts1966__intro {
  position: relative;
  text-align: center;
  text-transform: uppercase;
  color: #414042;
}

/* The centre rule: from the section's top down to the text here, and from the text to the
   section's bottom on .ts1966__photos. */
.ts1966__intro::before,
.ts1966__photos::before {
  content: "";
  position: absolute;
  left: 50%;
  border-left: 1px solid #d9d9d9;
}

.ts1966__intro::before {
  bottom: calc(100% + var(--ts1966-rule-gap-top));
  height: calc(var(--ts1966-pad-top) - var(--ts1966-rule-gap-top));
}

.ts1966__photos::before {
  top: var(--ts1966-rule-gap-bottom);
  bottom: 0;
}

/* Hidden until the text starts fading in: page.js adds is-revealed with the same trigger. */
.ts1966__intro::before,
.ts1966__photos::before {
  transition: opacity 0.9s ease;
}

.ts1966-js .ts1966__memories:not(.is-revealed) .ts1966__intro::before,
.ts1966-js .ts1966__memories:not(.is-revealed) .ts1966__photos::before {
  opacity: 0;
}

.ts1966__intro-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Scales with the headline (16px at 1440), floored at 11px. */
.ts1966__intro-kicker {
  margin: 0 0 24px;
  font-size: max(11px, min(16px, 1.111vw));
  line-height: 1.375;
  color: #666;
}

.ts1966__intro-headline {
  width: 55.76%; /* 803px of 1440: keeps the line breaks as the type scales */
  margin: 0;
  font-weight: 800;
  font-size: min(48px, 3.333vw);
  line-height: 1.5;
  letter-spacing: 0.01em;
}

/* Hidden until page.js fades them in (see the key visual). */
.ts1966__intro-line {
  display: block;
}

.ts1966-js .ts1966__intro-line {
  visibility: hidden;
}

/* Outlined text: a 2px stroke painted under a fill in the background colour leaves a 1px
   outline, and hides the lines where the font's glyph contours overlap (R, S, @…). */
.ts1966__intro-outline {
  display: block;
  color: #f1f1de;
  -webkit-text-stroke: 2px #414042;
  paint-order: stroke fill;
}

/* The track: its height and the photos' positions come from the Figma frame, so the gaps
   above the first photo and below the last are part of it. */
.ts1966__photos {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  aspect-ratio: var(--dratio);
}

/* Positioned, so they paint over the centre rule. The figure crops the image, so it can zoom
   in on hover inside the same frame; page.js moves the figure for the fade-up. */
.ts1966__photo {
  position: absolute;
  left: var(--dx);
  top: var(--dy);
  width: var(--dw);
  aspect-ratio: 3 / 2;
  margin: 0;
  overflow: hidden;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
  container-type: inline-size; /* the year sizes itself to the photo (cqw) */
}

.ts1966__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Seven-segment digits for the photo years: DSEG7 Classic 0.46 by keshikan, SIL Open Font
   License 1.1 (fonts/DSEG-LICENSE.txt), from the dseg npm package. */
@font-face {
  font-family: "DSEG7 Classic";
  src: url("fonts/DSEG7Classic-Italic.woff2") format("woff2");
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

/* The year, bottom right: always shown at 60%, in full on hover. Sized to the photo: --year
   is the font size in cqw (% of the photo's width), tuned on 2000 at 1440 (660px wide: 12px),
   within 12–16px. The offsets are in em, so they follow the font size (20px right, 16px bottom
   at 12px). */
.ts1966__photo-year {
  --year: clamp(12px, 1.82cqw, 16px);
  position: absolute;
  right: 1.667em;
  bottom: 1.333em;
  font-family: "DSEG7 Classic", monospace;
  font-size: var(--year);
  font-weight: normal;
  font-style: italic;
  line-height: 1;
  color: #ffaa33;
  text-shadow: 0 0 2px rgba(200, 150, 100, 0.8);
  opacity: 0.6;
  letter-spacing: 0.05em;
  transition: opacity 0.4s ease;
}

.ts1966__photo:hover .ts1966__photo-year {
  opacity: 1;
}

/* Mobile photos are 230–290px wide, so the year sits at the 12px floor, closer to the corner. */
@media (max-width: 767px) {
  .ts1966__photo-year {
    --year: clamp(12px, 1.82cqw, 16px);
    right: 1em;
    bottom: 0.833em;
  }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .ts1966__photo img {
    transition: transform 10s ease-out;
  }

  .ts1966__photo:hover img {
    transform: scale(1.05);
  }
}

/* Hidden until page.js fades them up (see .ts1966__intro-line). */
.ts1966-js .ts1966__photo {
  visibility: hidden;
}

/* ---------- Stories: featured card, then the grid ---------- */

.ts1966__stories-wrap {
  background: #fffff1;
}

.ts1966__stories {
  max-width: 1299px; /* 1269px of content */
  margin: 0 auto;
  padding: 93px 15px 89px;
}

.ts1966__card {
  display: block;
  color: #414042;
  text-decoration: none;
}

.ts1966__card:hover,
.ts1966__card:focus {
  color: #414042;
  text-decoration: none;
}

.ts1966__card-image {
  aspect-ratio: 16 / 10; /* the site's usual featured image (1200 × 750), so most show uncropped */
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.ts1966__card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.ts1966__card:hover .ts1966__card-image img {
  transform: scale(1.03);
}

.ts1966__card:hover .ts1966__card-title {
  text-decoration: underline;
}

.ts1966__card-category {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
}

.ts1966__card-title {
  margin: 0;
  font-family: inherit;
  font-weight: 700;
  color: #414042;
}

.ts1966__card-date {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
  text-transform: uppercase;
  color: #666;
}

/* Short rule above the date (featured card, and every card on mobile). */
.ts1966__card-date::before {
  content: "";
  display: none;
  width: 40px;
  border-top: 1px solid #d9d9d9;
}

/* Featured: image left, text right, full-width rule below. */
.ts1966__card--featured {
  display: grid;
  grid-template-columns: 600fr 598fr;
  column-gap: 69px;
  align-items: start;
  padding-bottom: 40px;
  border-bottom: 1px solid #d9d9d9;
}

.ts1966__card--featured .ts1966__card-title {
  max-width: 446px;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1.2;
}

.ts1966__card--featured .ts1966__card-date::before {
  display: block;
  margin: 40px 0;
}

/* Grid: 3 columns of 383px with a 1px rule centred in the 61px between them. */
.ts1966__cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 61px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.ts1966__cards > li {
  position: relative;
  margin: 0; /* site-wide `ul li` adds .5rem, which would break the column rules */
  padding-top: 32px; /* + the grid's 8px top margin = 40px between the rule above and the image */
}

.ts1966__cards > li:not(:nth-child(3n + 1))::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -31px;
  border-left: 1px solid #d9d9d9;
}

/* Fills the row, so the bottom rules line up across a row. */
.ts1966__cards .ts1966__card {
  height: 100%;
  padding-bottom: 60px;
  border-bottom: 1px solid #d9d9d9;
  text-align: center;
}

.ts1966__cards .ts1966__card-body {
  margin-top: 34px;
}

.ts1966__cards .ts1966__card-title {
  margin: 9px 36px 0;
  font-size: 25px;
  line-height: 1.36;
}

.ts1966__cards .ts1966__card-date {
  margin-top: 34px;
}

/* ---------- Tablet: 2 columns ---------- */

@media (max-width: 991px) {
  .ts1966__card--featured {
    column-gap: 40px;
  }

  .ts1966__card--featured .ts1966__card-title {
    font-size: 32px;
  }

  .ts1966__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ts1966__cards > li:not(:nth-child(3n + 1))::before {
    content: none;
  }

  .ts1966__cards > li:nth-child(2n)::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -31px;
    border-left: 1px solid #d9d9d9;
  }
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
  /* Key visual: mobile frame 376 × 441 below the header; the illustration bleeds a little. */
  .ts1966__hero-inner {
    aspect-ratio: 376 / 441;
  }

  .ts1966__hero-title {
    left: 3.19%;
    top: 6.35%;
    width: 48.14%;
  }

  .ts1966__hero-illustration {
    left: -2.93%;
    top: 31.75%;
    width: 104.52%;
  }

  .ts1966__hero-since {
    left: 57.18%;
    top: 88.89%;
    width: 36.79%;
  }

  /* Memories */
  .ts1966__memories {
    --ts1966-pad-top: 60px;
    --ts1966-rule-gap-top: 10px;
    --ts1966-rule-gap-bottom: 7px;
  }

  /* Sizes matched to the mobile frame's line widths (it sets these in Avenir Black, narrower
     than Montserrat): the longest line is 335px of 376, leaving ~20px each side. */
  .ts1966__intro-kicker {
    margin-bottom: 12px;
    font-size: min(11.5px, 3.07vw); /* scales down on screens narrower than 375 */
    line-height: 16px;
  }

  .ts1966__intro-headline {
    width: 100%;
    font-size: 5.35vw; /* 20px at 376 */
  }

  /* One zigzag column with fixed gaps instead of the desktop collage. */
  .ts1966__photos {
    display: flex;
    flex-direction: column;
    gap: 60px;
    aspect-ratio: auto;
    padding: 120px 0;
  }

  .ts1966__photo {
    position: relative;
    left: auto;
    top: auto;
    margin-left: var(--mx);
    width: var(--mw);
  }

  /* Stories */
  .ts1966__stories {
    padding: 42px 19px;
  }

  .ts1966__card-category {
    font-size: 12px;
    line-height: 16px;
    color: #6f5f2b;
  }

  .ts1966__card-date {
    font-size: 12px;
    line-height: 16px;
  }

  .ts1966__card-date::before {
    display: block;
  }

  /* Featured: stacked and centred. */
  .ts1966__card--featured {
    display: block;
    padding-bottom: 36px;
    text-align: center;
  }

  .ts1966__card--featured .ts1966__card-body {
    margin-top: 24px;
  }

  .ts1966__card--featured .ts1966__card-title {
    max-width: none;
    margin-top: 8px;
    font-size: 24px;
  }

  .ts1966__card--featured .ts1966__card-date::before {
    margin: 24px auto;
  }

  /* The rest: a list, image left and text right. */
  .ts1966__cards {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 36px;
  }

  .ts1966__cards > li {
    padding-top: 0;
  }

  .ts1966__cards > li + li {
    padding-top: 36px;
  }

  .ts1966__cards > li:nth-child(n)::before {
    content: none;
  }

  .ts1966__cards .ts1966__card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
    align-items: start;
    padding-bottom: 36px;
    text-align: left;
  }

  .ts1966__cards .ts1966__card-body {
    margin-top: 0;
  }

  .ts1966__cards .ts1966__card-title {
    margin: 8px 0 0;
    font-size: 24px;
    line-height: 1.2;
  }

  .ts1966__cards .ts1966__card-date {
    margin-top: 0;
  }

  .ts1966__cards .ts1966__card-date::before {
    margin: 16px 0;
  }
}
