/* ==========================================================================
   Base — Reset, Typography, Utilities
   ========================================================================== */

/* ── Skip Link ─────────────────────────────────────── */
.gx-skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 10000;
  padding: var(--gx-sp-2) var(--gx-sp-4);
  background: var(--gx-accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--gx-radius-sm);
}

.gx-skip-link:focus {
  position: fixed;
  top: var(--gx-sp-2);
  left: var(--gx-sp-2);
  width: auto;
  height: auto;
}

/* ── Screen Reader Only ───────────────────────────── */
.screen-reader-text {
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  width: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  word-wrap: normal !important;
}

/* ── Reset ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  font-size: 16px;
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
}

body {
  font-family: var(--gx-font-sans);
  font-size: var(--gx-text-base);
  line-height: var(--gx-leading-normal);
  color: var(--gx-text-primary);
  background-color: var(--gx-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

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

img {
  height: auto;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a,
button,
[role="button"],
input,
select,
textarea {
  touch-action: manipulation;
}

a {
  color: var(--gx-accent);
  text-decoration: none;
  transition: color var(--gx-transition);
}

a:hover {
  color: var(--gx-accent-hover);
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--gx-leading-tight);
  font-weight: 700;
  color: var(--gx-text-primary);
}

h1 { font-size: var(--gx-text-4xl); }
h2 { font-size: var(--gx-text-3xl); }
h3 { font-size: var(--gx-text-2xl); }
h4 { font-size: var(--gx-text-xl); }
h5 { font-size: var(--gx-text-lg); }
h6 { font-size: var(--gx-text-md); }

p {
  margin-bottom: var(--gx-sp-4);
}

p:last-child {
  margin-bottom: 0;
}

strong, b {
  font-weight: 600;
}

code {
  font-family: var(--gx-font-mono);
  font-size: 0.875em;
  background: var(--gx-bg-tertiary);
  padding: 0.15em 0.4em;
  border-radius: var(--gx-radius-sm);
}

::selection {
  background: rgba(var(--gx-accent-rgb), 0.3);
  color: var(--gx-text-primary);
}

/* ── Scrollbar (Webkit) ─────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--gx-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--gx-border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gx-text-muted);
}

/* ── Focus ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--gx-accent);
  outline-offset: 2px;
}

/* ── Utilities ──────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gx-text-muted); }
.text-secondary { color: var(--gx-text-secondary); }
.text-accent { color: var(--gx-accent); }

.mt-0  { margin-top: 0; }
.mt-2  { margin-top: var(--gx-sp-2); }
.mt-4  { margin-top: var(--gx-sp-4); }
.mt-6  { margin-top: var(--gx-sp-6); }
.mt-8  { margin-top: var(--gx-sp-8); }
.mb-0  { margin-bottom: 0; }
.mb-2  { margin-bottom: var(--gx-sp-2); }
.mb-4  { margin-bottom: var(--gx-sp-4); }
.mb-6  { margin-bottom: var(--gx-sp-6); }
.mb-8  { margin-bottom: var(--gx-sp-8); }

.pt-4  { padding-top: var(--gx-sp-4); }
.pb-4  { padding-bottom: var(--gx-sp-4); }
.px-4  { padding-left: var(--gx-sp-4); padding-right: var(--gx-sp-4); }
.py-4  { padding-top: var(--gx-sp-4); padding-bottom: var(--gx-sp-4); }

.hidden { display: none !important; }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Content Styles (for post content) ──────────────── */
.entry-content p {
  margin-bottom: var(--gx-sp-4);
}

.entry-content a {
  color: var(--gx-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.entry-content a:hover {
  color: var(--gx-accent-hover);
}

.entry-content ul,
.entry-content ol {
  margin-bottom: var(--gx-sp-4);
  padding-left: var(--gx-sp-6);
}

.entry-content ul {
  list-style: disc;
}

.entry-content ol {
  list-style: decimal;
}

.entry-content li {
  margin-bottom: var(--gx-sp-2);
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
  margin-top: var(--gx-sp-6);
  margin-bottom: var(--gx-sp-3);
}

.entry-content blockquote {
  border-left: 3px solid var(--gx-accent);
  padding-left: var(--gx-sp-4);
  color: var(--gx-text-secondary);
  margin-bottom: var(--gx-sp-4);
}

.entry-content img {
  border-radius: var(--gx-radius-md);
  margin: var(--gx-sp-4) 0;
}

/* WordPress gallery in entry content */
.entry-content .gallery {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gx-sp-2);
}

.entry-content .gallery-item {
  flex: 0 0 auto;
}

.entry-content .gallery-item img {
  margin: 0;
}

/* ==========================================================================
   View Transition API — Smooth cross-document page transitions
   ========================================================================== */
@view-transition {
  navigation: auto;
}

/* Named elements removed — sidebar and main-content depend on
   html.sidebar-open which is set by an inline <script>, but the
   view-transition snapshot captures state BEFORE the script runs,
   causing a close→reopen flash on navigation. These elements now
   transition as part of the root group (instant swap). */

/* Root: instant swap */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

/* Sidebar: slide left to leave, slide from left to enter */
::view-transition-old(sidebar) {
  animation: 200ms ease-out both gx-vt-sidebar-out;
}

::view-transition-new(sidebar) {
  animation: 200ms ease-in both gx-vt-sidebar-in;
}

/* Main content: crossfade */
::view-transition-old(main-content) {
  animation: 150ms ease both gx-vt-fade-out;
}

::view-transition-new(main-content) {
  animation: 200ms ease 50ms both gx-vt-fade-in;
}

@keyframes gx-vt-sidebar-out {
  to { opacity: 0; transform: translateX(-100%); }
}

@keyframes gx-vt-sidebar-in {
  from { opacity: 0; transform: translateX(-100%); }
}

@keyframes gx-vt-fade-out {
  to { opacity: 0; }
}

@keyframes gx-vt-fade-in {
  from { opacity: 0; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(main-content),
  ::view-transition-new(main-content),
  ::view-transition-old(sidebar),
  ::view-transition-new(sidebar) {
    animation: none;
  }
}

