/*
 * Reading layout (Medium-style) for long-form content.
 *
 * Kept outside main.css on purpose: main.css has hand edits that are not in
 * scss/, so recompiling the SCSS would drop them. Load order: after main.css.
 */

:root {
  --reading-width: 680px;
  --reading-wide: 960px;
  --reading-text: #242424;
  --reading-muted: #6b6b6b;
  --reading-accent: #C41F30;
}

/* Generic centered reading column */
.reading-col {
  max-width: var(--reading-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
  box-sizing: content-box;
}

/* main.css shrinks every <p> to 12px under 768px; undo that for reading text */
.reading-col p {
  font-size: inherit;
}

/* ---------- Heading letter-spacing ----------
 * main.css sets h1 6px / h2 4px. Wide tracking suits the short uppercase
 * English labels (OUR SERVICES, PROJECT REFERENCE) but breaks up Thai, which
 * has no spaces between words, so readers lose word shapes.
 * h1: keep the brand look but scale with font size (6px was 0.25em on mobile).
 * h2: mostly Thai sentences (article titles, course names), so no tracking.
 */
h1 {
  letter-spacing: normal;
}

h2 {
  letter-spacing: normal;
}

/* ---------- Services pages ---------- */

.services .head {
  padding: 56px 20px 8px;
}

.services .head h1 {
  font-size: 40px;
  line-height: 1.25;
  letter-spacing: normal;
  padding: 0;
  margin: 0 0 8px;
}

.services .head h2 {
  font-size: 26px;
  line-height: 1.4;
  font-weight: 400;
  color: var(--reading-text);
  padding: 0;
  margin: 0 0 40px;
}

.services .head .intro {
  font-size: 20px;
  font-weight: 300;
  line-height: 1.8;
  color: var(--reading-text);
  text-align: left;
}

.services .head .intro p {
  margin: 0 0 1.4em;
}

.services .head .intro h4 {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.5;
  margin: 2em 0 0.6em;
}

.services .head .intro ul {
  padding-left: 1.4em;
  margin: 0 0 1.4em;
}

.services .head .intro li {
  margin-bottom: 0.6em;
  padding-left: 0.2em;
}

.services .head .intro li::marker {
  color: var(--reading-accent);
}

.services .youtube-vdo {
  max-width: var(--reading-wide);
  margin: 40px auto 56px;
}

.services .step .detail {
  line-height: 1.8;
}

.services .step .detail h3 {
  line-height: 1.5;
}

@media (max-width: 991.98px) {
  /* container-xl already adds 15px; aim for ~24px total gutter */
  .services .head {
    padding: 32px 9px 8px;
  }
  .services .head h1 {
    font-size: 30px;
  }
  .services .head h2 {
    font-size: 20px;
    margin-bottom: 28px;
  }
  .services .head .intro {
    font-size: 18px;
  }
  .services .head .intro h4 {
    font-size: 20px;
  }
  .services .youtube-vdo {
    margin: 24px auto 32px;
  }
  .services .step .detail h3 {
    font-size: 22px;
    line-height: 1.5;
    padding: 0 20px;
  }
}

/* ---------- Global fixes ---------- */

/* main.css sets every <p> to 12px under 768px, which is too small to read on
   phones. Match the desktop base size instead. */
@media (max-width: 768px) {
  p {
    font-size: 16px;
  }
}

/* Summernote video embeds carry width="640" height="360"; main.css already
   makes them 100% wide, so keep the height in proportion. */
.note-video-clip {
  height: auto;
  aspect-ratio: 16 / 9;
}

/* ---------- Article detail page (knowledges, news & events) ---------- */

.article-page {
  padding-top: 48px;
}

.article-header {
  color: var(--reading-text);
}

.article-header .article-title {
  font-size: 36px;
  font-weight: 600;
  line-height: 1.4;
  padding: 0;
  margin: 0 0 16px;
}

.article-header .article-dek {
  font-size: 20px;
  font-weight: 300;
  line-height: 1.6;
  color: var(--reading-muted);
  margin: 0 0 20px;
}

.article-meta {
  font-size: 15px;
  font-weight: 300;
  color: var(--reading-muted);
}

.article-meta .dot {
  margin: 0 6px;
}

.article-hero {
  position: relative;
  max-width: var(--reading-wide);
  margin: 32px auto 40px;
}

.article-hero img {
  display: block;
  width: 100%;
  height: auto;
}

.article-hero .play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-size: 96px;
  line-height: 1;
  cursor: pointer;
}

/* Body text. Most articles were pasted from Word / Google Docs / Facebook and
   carry inline font-size, line-height and font-family; neutralise those so
   every article reads the same. */
.article-body {
  font-size: 20px;
  font-weight: 300;
  line-height: 1.8;
  color: var(--reading-text);
  padding-bottom: 64px;
  overflow-wrap: break-word;
}

.article-body p,
.article-body li,
.article-body span,
.article-body font,
.article-body div,
.article-body td,
.article-body th {
  font-size: inherit !important;
  line-height: inherit !important;
  font-family: inherit !important;
}

.article-body p {
  margin: 0 0 1em;
}

.article-body b,
.article-body strong {
  font-weight: 500;
}

/* Grey text from pasted content lowers contrast; keep brand red highlights */
.article-body font[color="#6c757d"],
.article-body font[color="#000000"] {
  color: inherit;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: normal;
  padding: 0;
  margin: 1.6em 0 0.5em;
}

.article-body h3,
.article-body h4 {
  font-size: 22px;
}

.article-body ul,
.article-body ol {
  padding-left: 1.4em;
  margin: 0 0 1em;
}

.article-body li {
  margin-bottom: 0.4em;
}

.article-body li::marker {
  color: var(--reading-accent);
}

.article-body img {
  display: block;
  max-width: 100% !important;
  height: auto !important;
  margin: 1.5em auto;
}

/* ---------- Image gallery (built by js/script/article-gallery.js) ----------
 * Runs of images from the rich-text editor become a carousel that breaks out of
 * the 680px text column to the hero width, so infographics stay legible.
 */
.article-gallery {
  --gallery-h: min(72vh, 620px);
  --gallery-w: min(var(--reading-wide), calc(100vw - 48px));
  position: relative;
  width: var(--gallery-w);
  margin: 2.25em 0 2.5em calc(50% - var(--gallery-w) / 2);
}

.article-gallery-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  outline: none;
}

.article-gallery-track::-webkit-scrollbar {
  display: none;
}

.article-gallery-track:focus-visible {
  box-shadow: 0 0 0 3px rgba(196, 31, 48, .35);
}

.article-gallery-slide {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--gallery-h);
  max-width: 86%;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid #ececec;
  overflow: hidden;
  cursor: zoom-in;
  text-decoration: none !important;
}

.article-body .article-gallery-slide img {
  display: block;
  width: auto;
  height: 100% !important;
  max-width: 100% !important;
  margin: 0;
  object-fit: contain;
  transition: transform .5s cubic-bezier(.16, 1, .3, 1);
}

.article-gallery-slide:hover img {
  transform: scale(1.02);
}

.article-gallery-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(36, 36, 36, .72);
  color: #fff;
  font-size: 14px;
  opacity: .85;
  transition: opacity .2s, background-color .2s;
}

.article-gallery-slide:hover .article-gallery-zoom,
.article-gallery-slide:focus-visible .article-gallery-zoom {
  opacity: 1;
  background: var(--reading-accent);
}

.article-gallery-slide:focus-visible {
  outline: 3px solid var(--reading-accent);
  outline-offset: -3px;
}

.article-gallery-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 16px;
}

.article-gallery-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #d6d6d6;
  border-radius: 50% !important; /* main.css forces square buttons site-wide */
  background: #fff;
  color: var(--reading-text);
  font-size: 15px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background-color .2s;
}

.article-gallery-btn:hover:not(:disabled) {
  border-color: var(--reading-accent);
  background: var(--reading-accent);
  color: #fff;
}

.article-gallery-btn:focus-visible {
  outline: 3px solid rgba(196, 31, 48, .35);
  outline-offset: 2px;
}

.article-gallery-btn:disabled {
  opacity: .35;
  cursor: default;
}

.article-gallery-count {
  min-width: 64px;
  text-align: center;
  font-size: 15px;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: var(--reading-muted);
}

@media (max-width: 767.98px) {
  /* Phones: slide width drives the height, so tall infographics are not letterboxed */
  .article-gallery {
    width: auto;
    margin-left: 0;
    margin-right: -24px;
  }
  .article-gallery-track {
    gap: 10px;
    padding-right: 24px;
  }
  .article-gallery-slide {
    height: auto;
    width: 86%;
    max-width: none;
  }
  .article-body .article-gallery-slide img {
    width: 100%;
    height: auto !important;
  }
  /* Too big for small infographics; tapping a slide still opens the zoom view */
  .article-gallery-zoom {
    display: none;
  }
}

/* Mouse users: show the zoom badge on hover only, it sits on top of image content */
@media (hover: hover) {
  .article-gallery-zoom {
    opacity: 0;
  }
}

/* Everything fits: no controls needed */
.article-gallery.is-static .article-gallery-bar {
  display: none;
}

/* ---------- Layout: spread ----------
 * Up to 3 images side by side at one shared height, like a magazine spread.
 * Phones fall back to the swipe carousel.
 */
@media (min-width: 768px) {
  .article-gallery[data-layout="spread"] .article-gallery-track {
    gap: 16px;
    overflow: visible;
  }
  .article-gallery[data-layout="spread"] .article-gallery-slide {
    flex: var(--ratio, 1) 1 0;
    min-width: 0;
    height: auto;
    max-width: none;
    border: 0;
  }
  .article-body .article-gallery[data-layout="spread"] .article-gallery-slide img {
    width: 100%;
    height: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .article-gallery-slide img {
    transition: none;
  }
  .article-gallery-slide:hover img {
    transform: none;
  }
}

.article-body iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  margin: 1.5em 0;
}

/* main.css hides all link styling site-wide; links in an article must look clickable */
.article-body a {
  color: var(--reading-accent) !important;
  text-decoration: underline !important;
  text-underline-offset: 3px;
}

.article-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 991.98px) {
  .article-page {
    padding-top: 24px;
  }
  .article-header .article-title {
    font-size: 26px;
  }
  .article-header .article-dek {
    font-size: 18px;
  }
  .article-body {
    font-size: 18px;
  }
  .article-body h1,
  .article-body h2 {
    font-size: 22px;
  }
  .article-body h3,
  .article-body h4 {
    font-size: 20px;
  }
  /* Medium-style edge-to-edge hero on phones */
  .article-hero {
    margin: 20px 0 28px;
  }
  .article-hero .play-btn {
    font-size: 64px;
  }
}

/* Article pages sit outside a .container, so set the ~24px phone gutter directly */
@media (max-width: 575.98px) {
  .article-page .reading-col,
  .article-body.reading-col {
    padding-left: 24px;
    padding-right: 24px;
  }
}
