/* ==========================================================================
   main.css — FangTech WordPress theme
   Ported from Astro src/styles/global.css
   ========================================================================== */

/* ==========================================================================
   Reset
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

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

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--size-base);
  line-height: var(--leading-normal);
  font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

img, picture, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

:target { scroll-margin-top: calc(var(--header-h) + 1.5rem); }

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--track-heading);
  text-wrap: balance;
}
h1 { font-size: var(--size-2xl); }
h2 { font-size: var(--size-xl); }
h3 { font-size: var(--size-lg); }

p, li, dd { text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: color 120ms ease, text-decoration-color 120ms ease;
}
a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

a:where(.post-item__title, .tag, .tag-cloud a, .site-header a, .site-footer a),
a.no-underline { text-decoration: none; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-control);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

blockquote {
  border-left: 2px solid var(--border-strong);
  padding-left: 1.25rem;
  color: var(--fg-muted);
  font-style: italic;
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:not(pre) > code {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.1em 0.35em;
}

kbd {
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  padding: 0.1em 0.4em;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Layout helpers
   ========================================================================== */

.wrap {
  width: 100%;
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

.wrap--prose { max-width: calc(var(--measure) + 2 * var(--page-pad)); }

main { flex: 1; }

.stack > * + * { margin-top: var(--stack-gap, 1rem); }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--page-pad);
  top: 0;
  z-index: 100;
  transform: translateY(-120%);
  background: var(--bg-raised);
  border: 1px solid var(--fg);
  padding: 0.6rem 1rem;
  font-size: var(--size-sm);
  transition: transform 120ms ease;
}
.skip-link:focus { transform: translateY(0.5rem); }

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--chrome-bg);
  color: var(--chrome-fg);
}

.site-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-header__brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.375rem;
  letter-spacing: var(--track-title);
  color: var(--chrome-fg);
  text-decoration: none;
  white-space: nowrap;
}
.site-header__brand:hover { color: var(--chrome-fg); opacity: 0.85; }

.site-header__nav { margin-left: auto; }

.nav-list {
  position: relative;
  display: flex;
  gap: 1.5rem;
  list-style: none;
  padding: 0; margin: 0;
  align-items: center;
}

.nav-item {
  position: relative;
  display: inline-flex;
}

.nav-link {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: var(--track-heading);
  text-transform: uppercase;
  color: var(--chrome-fg-muted);
  text-decoration: none;
  padding-block: 0.35rem;
  transition: color 140ms ease;
}
.nav-link:hover { color: var(--chrome-fg); }
.nav-link[aria-current='page'] { color: var(--chrome-fg); }

.nav-indicator {
  position: absolute;
  bottom: -2px; left: 0;
  height: 2px;
  background: #2b66ff;
  border-radius: 2px;
  pointer-events: none;
  opacity: 0;
  will-change: transform, width, opacity;
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    width 220ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 180ms ease;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-header__search {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  color: var(--chrome-fg-muted);
  text-decoration: none;
  border-radius: var(--radius-control);
  transition: color 120ms ease;
}
.site-header__search:hover { color: var(--chrome-fg); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  font-size: var(--size-sm);
  line-height: 1;
  color: var(--chrome-fg-muted);
  background: none;
  border: 1px solid var(--chrome-border);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.theme-toggle:hover {
  color: var(--chrome-fg);
  border-color: var(--chrome-fg-muted);
}

@media (max-width: 52rem) {
  .site-header__inner {
    flex-wrap: wrap;
    height: auto;
    padding-block: 0.75rem;
    gap: 0.75rem 1rem;
  }
  .site-header__nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }
  .nav-list { gap: 1rem; }
  .site-header__actions { margin-left: auto; }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  background: var(--chrome-bg);
  color: var(--chrome-fg);
  margin-top: 4rem;
  padding-block: 3rem 2.5rem;
  font-size: var(--size-sm);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.site-footer__copy {
  color: var(--chrome-fg-muted);
  font-size: var(--size-xs);
}

.site-footer__links ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  list-style: none;
  padding: 0;
}

.site-footer__links a {
  font-family: var(--font-heading);
  font-size: var(--size-xs);
  font-weight: 700;
  letter-spacing: var(--track-title);
  text-transform: uppercase;
  color: var(--chrome-fg-muted);
  text-decoration: none;
  transition: color 120ms ease;
}
.site-footer__links a:hover { color: var(--chrome-fg); }

/* ==========================================================================
   Section furniture
   ========================================================================== */

.section { padding-block: 3.5rem; }
.section + .section { border-top: 1px solid var(--border); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: var(--track-heading);
  text-transform: uppercase;
  color: var(--fg);
}

.section-link {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: var(--track-heading);
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
}
.section-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ==========================================================================
   Post list
   ========================================================================== */

.post-list {
  list-style: none;
  padding: 0;
  border-top: 1px solid var(--border);
}
.post-list > li { border-bottom: 1px solid var(--border); }
.post-list a { text-decoration: none; color: inherit; }

.post-item {
  display: grid;
  gap: 0.5rem 1.5rem;
  padding-block: 1.5rem;
  grid-template-columns: 8.5rem 1fr;
}

@media (max-width: 40rem) {
  .post-item { grid-template-columns: 1fr; }
}

.post-item__date {
  font-size: var(--size-xs);
  color: var(--fg-subtle);
  letter-spacing: 0.05em;
  padding-top: 0.35em;
  white-space: nowrap;
}

.post-item__body {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.post-item__title {
  font-size: var(--size-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

a:hover .post-item__title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.post-item__desc {
  font-size: var(--size-sm);
  color: var(--fg-muted);
  max-width: var(--measure);
  line-height: 1.6;
}

.post-item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  font-size: var(--size-xs);
  color: var(--fg-subtle);
}

.post-item__thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 240px;
}

/* ==========================================================================
   Tags
   ========================================================================== */

.tag {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--radius-control);
  padding: 0.15rem 0.45rem;
  transition: background 120ms ease, color 120ms ease;
}
a.tag:hover {
  background: var(--accent);
  color: var(--bg);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
}

/* ==========================================================================
   Prose
   ========================================================================== */

.prose {
  max-width: var(--measure);
  font-size: var(--size-base);
  line-height: var(--leading-prose);
}

.prose > * + * { margin-top: 1.35em; }

.prose h2, .prose h3, .prose h4 {
  margin-top: 2.5em;
  margin-bottom: -0.35em;
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
}

.prose h2 {
  font-size: var(--size-lg);
  padding-bottom: 0.4em;
  border-bottom: 1px solid var(--border);
}

.prose h3 { font-size: var(--size-md); }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--fg-subtle); }
.prose img { width: 100%; background: var(--bg-sunken); }
.prose img:not([width]) { aspect-ratio: 16 / 9; object-fit: cover; }
.prose figure { margin-inline: 0; }
.prose figcaption { font-size: var(--size-xs); color: var(--fg-subtle); margin-top: 0.6em; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-sm);
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.prose thead { border-bottom: 1px solid var(--border-strong); }
.prose th { text-align: left; font-weight: 700; white-space: nowrap; padding: 0.6rem 1rem 0.6rem 0; }
.prose td { padding: 0.6rem 1rem 0.6rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th + th, .prose td + td { padding-left: 1rem; }
.prose tbody tr:last-child td { border-bottom: 0; }

.prose pre {
  overflow-x: auto;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised) !important;
  font-size: var(--size-sm);
  line-height: 1.6;
}
.prose pre code { background: none; border: 0; padding: 0; }

/* ==========================================================================
   Responsive video embeds
   ========================================================================== */

.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin-block: 2rem;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}
.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* WordPress oembed wrapper */
.wp-block-embed__wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
}
.wp-block-embed__wrapper iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

/* ==========================================================================
   Utility
   ========================================================================== */

.lede { font-size: var(--size-md); line-height: 1.6; color: var(--fg-muted); max-width: var(--measure); }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }
.meta { font-size: var(--size-xs); color: var(--fg-subtle); letter-spacing: 0.05em; }
.divider { border-top: 1px solid var(--border); margin-block: 2.5rem; }

.button {
  display: inline-block;
  font-size: var(--size-sm);
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 120ms ease;
}
.button:hover { opacity: 0.8; text-decoration: none; }

.button--ghost { background: transparent; color: var(--fg); }
.button--ghost:hover { background: var(--bg-sunken); opacity: 1; }

/* ==========================================================================
   Single post
   ========================================================================== */

.post-header { padding-block: 3rem 2rem; }
.post-header__category { margin-bottom: 1rem; }
.post-header__title { font-size: clamp(1.75rem, 4vw, var(--size-3xl)); margin-bottom: 1.25rem; }
.post-header__meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; color: var(--fg-subtle); font-size: var(--size-xs); }
.post-header__meta a { color: inherit; text-decoration: none; }
.post-header__meta a:hover { color: var(--fg); }
.post-header__cover { margin-bottom: 3rem; }
.post-header__cover img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); }

/* Author box */
.author-box {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 3rem;
}

.author-box__avatar { flex-shrink: 0; border-radius: 50%; }
.author-box__name { font-weight: 700; margin-bottom: 0.35rem; }
.author-box__bio { font-size: var(--size-sm); color: var(--fg-muted); line-height: 1.6; }
.author-box__link { font-size: var(--size-sm); color: var(--accent); text-decoration: none; margin-top: 0.5rem; display: inline-block; }
.author-box__link:hover { text-decoration: underline; }

/* Post navigation */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: var(--size-sm);
}
.post-nav a { color: inherit; text-decoration: none; }
.post-nav a:hover { color: var(--accent); }
.post-nav__label { font-size: var(--size-xs); color: var(--fg-subtle); text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 0.4rem; }

/* ==========================================================================
   Comments
   ========================================================================== */

.comments-area { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.comments-title { font-size: var(--size-lg); margin-bottom: 2rem; }

.comment-list { list-style: none; padding: 0; }
.comment-list li { margin-bottom: 1.5rem; }

.comment-body {
  padding: 1.25rem;
  background: var(--bg-sunken);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.comment-author .fn { font-weight: 700; }
.comment-meta { font-size: var(--size-xs); color: var(--fg-subtle); margin-top: 0.25rem; }
.comment-content { margin-top: 0.75rem; font-size: var(--size-sm); line-height: 1.6; }
.comment-reply-link { font-size: var(--size-xs); color: var(--accent); text-decoration: none; }
.comment-reply-link:hover { text-decoration: underline; }

.must-log-in, .logged-in-as {
  font-size: var(--size-sm);
  color: var(--fg-muted);
  margin-bottom: 1.5rem;
}

.comment-form label { display: block; font-size: var(--size-sm); font-weight: 600; margin-bottom: 0.35rem; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--bg);
  font-size: var(--size-sm);
  margin-bottom: 1rem;
}
.comment-form input:focus,
.comment-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.comment-form textarea { min-height: 140px; resize: vertical; }
.comment-form .form-submit { margin-top: 0.5rem; }
.comment-form .submit {
  padding: 0.65rem 1.5rem;
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  border-radius: var(--radius-control);
  cursor: pointer;
  font-weight: 600;
  transition: opacity 120ms ease;
}
.comment-form .submit:hover { opacity: 0.8; }

/* ==========================================================================
   Search & 404
   ========================================================================== */

.search-form { display: flex; gap: 0.5rem; margin-bottom: 2rem; }
.search-field {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--bg);
  font-size: var(--size-sm);
}
.search-field:focus { outline: 2px solid var(--accent); border-color: transparent; }
.search-submit {
  padding: 0.65rem 1.25rem;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-control);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--size-sm);
}

/* ==========================================================================
   Author page
   ========================================================================== */

.author-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  padding-block: 3rem 2rem;
}
.author-header__avatar { flex-shrink: 0; border-radius: 50%; }
.author-header__name { font-size: var(--size-2xl); margin-bottom: 0.5rem; }
.author-header__bio { color: var(--fg-muted); line-height: 1.6; max-width: var(--measure); }

/* ==========================================================================
   Tables & Discount codes page
   ========================================================================== */

.wp-block-table {
  overflow-x: auto;
  margin-block: 1.5rem;
}

.wp-block-table table,
.prose table,
.discount-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-sm);
  color: var(--fg);
}

.wp-block-table th,
.prose th,
.discount-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 2px solid var(--border-strong);
  font-family: var(--font-heading);
  font-size: var(--size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--fg);
  background: var(--bg-sunken);
}

.wp-block-table td,
.prose td,
.discount-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: middle;
}

/* Override WordPress default .is-style-stripes to prevent unreadable light rows in dark mode */
.wp-block-table.is-style-stripes {
  border-bottom: 1px solid var(--border) !important;
}

.wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
  background-color: var(--bg-sunken) !important;
}

.wp-block-table.is-style-stripes tbody tr:nth-child(even) {
  background-color: var(--bg) !important;
}

.wp-block-table.is-style-stripes tbody tr:hover td,
.wp-block-table table tr:hover td,
.discount-table tr:hover td {
  background-color: var(--bg-raised);
}

/* Discount code pill */
.discount-code,
.wp-block-table code,
.prose table code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--bg-raised) !important;
  color: #0038ff !important;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 0.25rem 0.6rem;
  user-select: all;
}

:root[data-theme='dark'] .discount-code,
:root[data-theme='dark'] .wp-block-table code,
:root[data-theme='dark'] .prose table code {
  background: #1e2430 !important;
  color: #70a1ff !important;
  border-color: rgba(112, 161, 255, 0.4);
}

/* Links inside tables */
.wp-block-table a,
.prose table a,
.discount-table a {
  color: #0038ff;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

:root[data-theme='dark'] .wp-block-table a,
:root[data-theme='dark'] .prose table a,
:root[data-theme='dark'] .discount-table a {
  color: #70a1ff;
  text-decoration-color: rgba(112, 161, 255, 0.4);
}

:root[data-theme='dark'] .wp-block-table a:hover,
:root[data-theme='dark'] .prose table a:hover,
:root[data-theme='dark'] .discount-table a:hover {
  color: #ffffff;
  text-decoration-color: #ffffff;
}
