/**
 * AVThai UI — readable, memorable, modern media-database look
 * Brand: ember coral + ink navy (not purple / cream-terracotta cliché)
 */

:root {
  --av-ink: #0e1a2b;
  --av-ink-2: #152338;
  --av-ember: #ff4d3a;
  --av-ember-deep: #d93626;
  --av-sand: #f3efe6;
  --av-mist: #e8eef6;
  --av-text: #1a2433;
  --av-muted: #5a6a7e;
  --av-line: rgba(14, 26, 43, 0.12);
  --av-surface: rgba(255, 255, 255, 0.72);
  --av-radius: 12px;
  --av-font: Tahoma, "Leelawadee UI", "Noto Sans Thai", Arial, sans-serif;
  --av-display: Tahoma, "Leelawadee UI", "Noto Sans Thai", Arial, sans-serif;
  --av-fs-base: 1rem;
  --av-fs-h1: clamp(1.35rem, 1.2rem + 0.6vw, 1.75rem);
  --av-fs-h2: clamp(1.1rem, 1.05rem + 0.25vw, 1.3rem);
  --av-fs-h3: clamp(1.02rem, 1rem + 0.15vw, 1.15rem);
}

html[data-theme="dark"],
body.dark,
[data-theme="dark"] {
  --av-text: #eef2f7;
  --av-muted: #a8b3c4;
  --av-line: rgba(255, 255, 255, 0.12);
  --av-surface: rgba(21, 35, 56, 0.88);
  --av-sand: #1a2740;
  --av-ink: #f5f7fb;
}

html {
  font-size: 16px !important;
  scroll-behavior: smooth;
}

body {
  font-family: var(--av-font) !important;
  font-size: var(--av-fs-base) !important;
  line-height: 1.55;
  color: var(--av-text);
}

html:not([data-theme="dark"]) body {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(255, 77, 58, 0.14), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, rgba(21, 35, 56, 0.08), transparent 50%),
    linear-gradient(180deg, #f7f4ee 0%, #eef2f7 45%, #f5f7fb 100%) !important;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(255, 77, 58, 0.18), transparent 50%),
    radial-gradient(800px 400px at 100% 10%, rgba(80, 120, 200, 0.12), transparent 55%),
    linear-gradient(180deg, #0b1220 0%, #121c2e 50%, #0e1624 100%) !important;
}

h1, h2, h3, .h1, .h2, .h3,
.page-title, .entry-title, .post-title {
  font-family: var(--av-display) !important;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--av-ink);
  line-height: 1.25;
}

h1, .h1,
h1.page-title,
h1.widget-title,
.archive h1.page-title {
  font-size: var(--av-fs-h1) !important;
}
h2, .h2 { font-size: var(--av-fs-h2) !important; }
h3, .h3 { font-size: var(--av-fs-h3) !important; }

/* Archive titles were .h5 — keep readable but not oversized */
.page-title.widget-title.h5,
h1.page-title.h5 {
  font-size: clamp(1.2rem, 1.1rem + 0.4vw, 1.45rem) !important;
  font-weight: 700 !important;
}

a {
  color: var(--av-ember-deep);
  text-underline-offset: 0.15em;
  transition: color 0.18s ease, opacity 0.18s ease;
}
a:hover { color: var(--av-ember); }

/* Brand H1 on Elementor home — visible, not sr-only */
.avthai-site-hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1rem 0.35rem;
}
.avthai-site-h1 {
  margin: 0;
  font-size: clamp(1.4rem, 1.25rem + 0.7vw, 1.85rem) !important;
  color: var(--av-ink);
  position: relative;
}
.avthai-site-h1::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: 0.4rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--av-ember), transparent);
}
.avthai-site-tagline {
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
  color: var(--av-muted);
  max-width: 40rem;
  line-height: 1.45;
}

/* Header / nav — keep clickable above Elementor full-height sections */
#site-header,
.site-header,
header.header {
  position: sticky;
  top: 0;
  z-index: 1050 !important;
  background: linear-gradient(180deg, rgba(14, 26, 43, 0.97), rgba(21, 35, 56, 0.94)) !important;
  border-bottom: 1px solid rgba(255, 77, 58, 0.35);
  pointer-events: auto;
}

#site-header a,
.site-header a,
header.header a,
.navbar .nav-link {
  color: #f5f7fb !important;
  font-weight: 600;
  font-size: 0.95rem !important;
  pointer-events: auto;
}

#site-header .navbar-toggler,
#site-header .toggle-search,
#site-header .btn {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}

#site-header a:hover,
.navbar .nav-link:hover {
  color: var(--av-ember) !important;
}

.site-branding .site-title,
.navbar-brand {
  font-family: var(--av-display) !important;
  font-weight: 800 !important;
  font-size: clamp(1.1rem, 1rem + 0.35vw, 1.35rem) !important;
  color: #fff !important;
  letter-spacing: -0.02em;
}

/* Search */
.form-control,
input[type="search"],
input[type="text"],
.search-form input {
  font-size: 0.95rem !important;
  min-height: 2.4rem;
  border-radius: 10px !important;
  border: 1px solid var(--av-line) !important;
}

.btn, button, .button,
input[type="submit"] {
  font-family: var(--av-font) !important;
  font-weight: 600 !important;
  font-size: 0.95rem !important;
  border-radius: 10px !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-primary,
.button-primary,
button[type="submit"],
.btn.btn-danger {
  background: linear-gradient(180deg, var(--av-ember), var(--av-ember-deep)) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(217, 54, 38, 0.28);
}
.btn-primary:hover,
button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(217, 54, 38, 0.35);
}

/* Video cards — interaction containers, not decorative clutter */
.post-item,
.video-item,
.card-video,
.archive-item,
.thumbnail-wrap {
  border-radius: var(--av-radius) !important;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.post-item:hover,
.video-item:hover,
.card-video:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(14, 26, 43, 0.14);
}

.post-item .post-title,
.video-item .entry-title,
.card-video .title,
.archive .entry-title a {
  font-size: clamp(0.9rem, 0.85rem + 0.2vw, 1rem) !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  color: var(--av-ink) !important;
}

.post-thumbnail img,
.thumbnail-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Single video */
.single-video .entry-title,
.single .entry-title {
  font-size: clamp(1.25rem, 1.15rem + 0.5vw, 1.6rem) !important;
  margin-bottom: 0.6rem;
}

.single-video .entry-content,
.single .entry-content,
.avthai-media-entry {
  font-size: 0.98rem;
  max-width: 48rem;
}

.avthai-media-entry {
  margin: 1.25rem 0 1.75rem;
  padding: 1.25rem 1.35rem;
  background: linear-gradient(145deg, #fff 0%, var(--av-sand) 100%);
  border: 1px solid var(--av-line);
  border-radius: var(--av-radius);
  border-left: 4px solid var(--av-ember);
}
.avthai-media-entry__title {
  margin: 0 0 0.4rem !important;
  font-size: 1.1rem !important;
}
.avthai-media-entry__meta {
  margin: 0.65rem 0;
  padding-left: 1.1rem;
}
.avthai-media-entry__meta li { margin-bottom: 0.3rem; }

/* Breadcrumb */
.breadcrumb,
.rank-math-breadcrumb {
  font-size: 0.875rem !important;
  color: var(--av-muted);
  padding: 0.5rem 0;
}
.breadcrumb a { font-weight: 600; }

.avthai-breadcrumb {
  overflow-x: auto;
  padding: 0.75rem 0 0.25rem;
  color: var(--av-muted);
  font-size: 0.875rem;
  scrollbar-width: none;
}
.avthai-breadcrumb::-webkit-scrollbar { display: none; }
.avthai-breadcrumb ol {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
}
.avthai-breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(34rem, 68vw);
}
.avthai-breadcrumb li:not(:last-child)::after {
  content: "/";
  color: color-mix(in srgb, var(--av-muted) 55%, transparent);
}
.avthai-breadcrumb a {
  color: var(--av-muted);
  font-weight: 600;
  text-decoration: none;
}
.avthai-breadcrumb [aria-current="page"] {
  overflow: hidden;
  color: var(--av-text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Taxonomy / archive headers */
.archive-header,
.page-header,
.taxonomy-header {
  padding: 0.85rem 0 0.5rem;
}
.archive-description,
.term-description {
  font-size: 0.95rem;
  color: var(--av-muted);
  max-width: 52rem;
  line-height: 1.7;
}

.archive-video .post-item {
  border: 1px solid var(--av-line);
  background: var(--av-surface);
  box-shadow: 0 8px 24px rgba(14, 26, 43, 0.06);
}

/* Helpful, scannable dead-end page. */
.error-404-wrap {
  display: grid;
  min-height: min(62vh, 38rem);
  place-items: center;
}
.error-404-wrap > div {
  width: min(100%, 44rem);
}
.error-404-wrap .error-code {
  margin: 0;
  color: var(--av-ember);
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 800;
  line-height: 1;
}
.error-404-wrap .error-title {
  margin: 0.65rem 0;
  font-size: clamp(1.45rem, 1.2rem + 1vw, 2.1rem) !important;
}
.error-404-wrap .error-search {
  max-width: 32rem;
}

/* Pagination */
.pagination .page-numbers,
.nav-links a,
.page-numbers {
  font-size: 0.9rem !important;
  min-width: 2.25rem;
  min-height: 2.25rem;
  border-radius: 8px !important;
  font-weight: 600;
}
.pagination .current,
.page-numbers.current {
  background: #0e1a2b !important;
  color: #fff !important;
}
html[data-theme="dark"] .pagination .current,
html[data-theme="dark"] .page-numbers.current {
  background: var(--av-ember-deep) !important;
}

/* Footer */
#site-footer,
.site-footer,
footer.footer {
  background: #0e1a2b !important;
  color: rgba(255, 255, 255, 0.82) !important;
  font-size: 0.9rem;
}
#site-footer a,
.site-footer a {
  color: #ffd4ce !important;
}

/* Motion: presence, not noise */
@media (prefers-reduced-motion: no-preference) {
  .avthai-site-h1 {
    animation: avthai-fade-up 0.55s ease both;
  }
  .post-item,
  .video-item,
  .card-video {
    animation: avthai-fade-up 0.45s ease both;
  }
}
@keyframes avthai-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Mobile */
@media (max-width: 767.98px) {
  html { font-size: 16px; }
  .avthai-site-h1 {
    padding-inline: 0.85rem;
    font-size: 1.35rem !important;
  }
  .single-video .entry-title {
    font-size: 1.2rem !important;
  }
  .btn, button, input[type="submit"] {
    min-height: 44px;
    width: auto;
  }

  .pagination .page-numbers,
  .nav-links a,
  .page-numbers {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------------------------
 * Video detail page
 * A compact, touch-friendly reading hierarchy for long Thai titles.
 * ----------------------------------------------------------------------- */

body.single-video {
  --av-video-surface: rgba(255, 255, 255, 0.94);
  --av-video-soft: #f5f7fa;
  --av-video-chip: #edf1f6;
  --av-video-shadow: 0 16px 44px rgba(14, 26, 43, 0.09);
}

html[data-theme="dark"] body.single-video {
  --av-video-surface: #152338;
  --av-video-soft: #111d30;
  --av-video-chip: #22324a;
  --av-video-shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
}

/* The original py-4 header is too tall above a media player. */
body.single-video #site-header {
  min-height: 64px;
  padding-top: 0.65rem !important;
  padding-bottom: 0.65rem !important;
}

body.single-video #site-header .custom-logo {
  width: auto;
  max-height: 42px;
}

body.single-video .section-player {
  margin-bottom: 1.5rem !important;
  padding: 1.25rem 0;
  background: #060a11 !important;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

body.single-video .section-player .post-main {
  max-width: 1180px;
  margin-inline: auto;
}

body.single-video .player-wrapper,
body.single-video .player-wrapper-ratio,
body.single-video .player-embed {
  border-radius: 14px;
  overflow: hidden;
}

body.single-video .player-wrapper {
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

body.single-video .player-header {
  min-height: 48px;
  background: linear-gradient(180deg, #172238, #101a2b);
}

body.single-video .player-header .post-title {
  min-width: 0;
  margin: 0 1rem 0 0;
  overflow: hidden;
  color: #f7f9fc !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.single-video .player-header .btn-close {
  flex: 0 0 auto;
  opacity: 0.72;
  filter: invert(1);
}

body.single-video .player-header .btn-close:hover {
  opacity: 1;
}

body.single-video .page-main > .container {
  padding-bottom: 2rem;
}

body.single-video .page-main .shadow-sm.rounded.bg-white,
body.single-video #post-bottom,
body.single-video .widget-primary {
  border: 1px solid var(--av-line);
  background: var(--av-video-surface) !important;
  box-shadow: var(--av-video-shadow) !important;
}

body.single-video .page-main .shadow-sm.rounded.bg-white,
body.single-video #post-bottom {
  border-radius: 16px !important;
  overflow: hidden;
}

body.single-video .post-bottom__meta {
  padding: clamp(1.15rem, 2.5vw, 1.75rem) !important;
  border-color: var(--av-line) !important;
}

body.single-video h1.post-title.post-title-xl {
  max-width: 46rem;
  margin: 0 0 0.8rem;
  color: var(--av-text) !important;
  font-size: clamp(1.28rem, 1.06rem + 0.72vw, 1.75rem) !important;
  font-weight: 700 !important;
  line-height: 1.48;
  letter-spacing: -0.012em;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

body.single-video .post-bottom__meta .post-meta__items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
  color: var(--av-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

body.single-video .post-bottom__meta .post-meta__items > * {
  margin: 0 !important;
}

body.single-video .post-bottom__meta .post-meta__items a {
  color: var(--av-muted);
  font-weight: 500;
}

body.single-video .post-bottom__meta .post-meta__items a:hover {
  color: var(--av-ember);
}

/* Categories become scan-friendly chips instead of one long slash-separated line. */
body.single-video .post-bottom__meta .post-terms.post-categories {
  display: flex;
  flex: 0 0 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem !important;
}

body.single-video .post-bottom__meta .post-terms.post-categories a,
body.single-video .post-tags a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.35rem 0.72rem;
  border: 1px solid var(--av-line);
  border-radius: 999px;
  background: var(--av-video-chip);
  color: var(--av-text) !important;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

body.single-video .post-bottom__meta .post-terms.post-categories a:hover,
body.single-video .post-tags a:hover {
  border-color: rgba(255, 77, 58, 0.55);
  background: rgba(255, 77, 58, 0.11);
  color: var(--av-ember) !important;
}

body.single-video .post-bottom__meta .post-terms.post-categories .sep {
  display: none;
}

body.single-video .post-bottom__meta .post-terms.post-categories > .btn__icon {
  margin-right: 0.1rem;
  color: var(--av-muted);
}

body.single-video .post-options {
  padding-top: 1rem !important;
}

body.single-video .video-small-controls .btn,
body.single-video .post-options .btn,
body.single-video .post-options button {
  min-width: 42px;
  min-height: 42px;
}

body.single-video .post-bottom__content {
  padding: clamp(1.15rem, 2.5vw, 1.75rem) !important;
}

body.single-video .post-bottom__content .post-content {
  max-width: 48rem;
  color: var(--av-text);
  font-size: 1rem;
  line-height: 1.78;
}

body.single-video .post-bottom__content .post-content p {
  margin-bottom: 1rem;
}

body.single-video .post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1.1rem;
}

body.single-video #content-bottom {
  margin-top: 1.75rem;
}

body.single-video #content-bottom .widget-title-wrap,
body.single-video #sidebar-primary .widget-title-wrap {
  margin-bottom: 1rem;
}

body.single-video #content-bottom .widget-title,
body.single-video #sidebar-primary .widget-title {
  margin: 0;
  color: var(--av-text) !important;
  font-size: clamp(1.08rem, 1rem + 0.25vw, 1.25rem) !important;
  font-weight: 700 !important;
  line-height: 1.4;
}

body.single-video #content-bottom .widget-title .title-icon,
body.single-video #sidebar-primary .widget-title .title-icon {
  margin-right: 0.55rem;
  color: var(--av-ember);
}

body.single-video #content-bottom .post-item {
  margin-bottom: 1.15rem !important;
}

body.single-video #content-bottom .post-thumbnail {
  border-radius: 12px !important;
}

body.single-video #content-bottom .post-meta__title {
  margin: 0;
}

body.single-video #content-bottom .post-meta__title a {
  display: -webkit-box;
  overflow: hidden;
  color: var(--av-text) !important;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.48;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

body.single-video #content-bottom .post-meta__items {
  margin-top: 0.35rem;
  color: var(--av-muted);
  font-size: 0.82rem;
}

body.single-video #sidebar-primary .widget-primary {
  margin-bottom: 1rem;
  padding: 1.1rem;
  border-radius: 14px;
}

body.single-video a:focus-visible,
body.single-video button:focus-visible,
body.single-video input:focus-visible {
  outline: 3px solid rgba(255, 77, 58, 0.48) !important;
  outline-offset: 3px;
}

@media (max-width: 991.98px) {
  body.single-video .section-player {
    padding: 0;
  }

  body.single-video .section-player > .container {
    max-width: none;
    padding-inline: 0;
  }

  body.single-video .player-wrapper,
  body.single-video .player-wrapper-ratio,
  body.single-video .player-embed {
    border-radius: 0;
  }

  body.single-video #sidebar-primary {
    margin-top: 1.5rem;
  }
}

@media (max-width: 575.98px) {
  body.single-video #site-header {
    min-height: 56px;
    padding-top: 0.45rem !important;
    padding-bottom: 0.45rem !important;
  }

  body.single-video #site-header .custom-logo {
    max-height: 36px;
  }

  body.single-video .section-player {
    margin-bottom: 1rem !important;
  }

  body.single-video .player-header {
    min-height: 42px;
    padding: 0.65rem 0.85rem !important;
  }

  body.single-video .player-header .post-title {
    font-size: 0.88rem !important;
  }

  body.single-video .page-main > .container {
    padding-inline: 0.75rem;
  }

  body.single-video h1.post-title.post-title-xl {
    font-size: 1.22rem !important;
    line-height: 1.5;
  }

  body.single-video .page-main .shadow-sm.rounded.bg-white,
  body.single-video #post-bottom {
    border-radius: 13px !important;
  }

  body.single-video .post-bottom__meta,
  body.single-video .post-bottom__content {
    padding: 1rem !important;
  }

  body.single-video .post-bottom__meta .post-meta__items {
    gap: 0.3rem 0.65rem;
    font-size: 0.86rem;
  }

  body.single-video .post-bottom__meta .post-terms.post-categories a,
  body.single-video .post-tags a {
    min-height: 36px;
    font-size: 0.84rem;
  }

  body.single-video .post-bottom__content .post-content {
    font-size: 0.96rem;
    line-height: 1.75;
  }

  body.single-video #content-bottom .post-grid > .row {
    --bs-gutter-x: 0.75rem;
  }

  body.single-video #content-bottom .post-meta__title a {
    font-size: 0.88rem;
  }
}
