/*
 * Tension v1 — Base layer (architectural wireframe)
 * Sharp corners (0 radius), hairline dividers (#E4E4E7), zero shadows.
 */

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

html {
  scroll-behavior: auto;
  -webkit-text-size-adjust: 100%;
  background-color: var(--lc-background);
}

/* Keep window.scrollY; overlays (.lc-mobile-nav, .lc-lightbox) are fixed.
   Only lock html — overflow:hidden on body can clip position:fixed children. */
html.lc-scroll-lock {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding-top: 4rem;
  font-family: var(--lc-font-body);
  font-size: var(--lc-text-body-md);
  line-height: 1.6;
  color: var(--lc-on-surface);
  background-color: var(--lc-background);
  overflow-x: hidden;
}

/* Cross-document View Transitions (progressive enhancement) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

html[data-lc-theme-dir]::view-transition-old(root) {
  z-index: 1;
}

html[data-lc-theme-dir]::view-transition-new(root) {
  z-index: 2147483646;
}

html[data-lc-theme-dir="to-dark"]::view-transition-old(root) {
  z-index: 2147483646;
  animation-name: lc-theme-wipe-down;
  animation-duration: 500ms;
  animation-timing-function: ease-in;
  animation-fill-mode: both;
}

html[data-lc-theme-dir="to-dark"]::view-transition-new(root) {
  z-index: 1;
  animation: none;
}

html[data-lc-theme-dir="to-light"]::view-transition-old(root) {
  z-index: 1;
  animation: none;
}

html[data-lc-theme-dir="to-light"]::view-transition-new(root) {
  z-index: 2147483646;
  animation-name: lc-theme-wipe-up;
  animation-duration: 500ms;
  animation-timing-function: ease-in;
  animation-fill-mode: both;
}

@keyframes lc-theme-wipe-down {
  from { clip-path: inset(0); }
  to { clip-path: inset(100% 0 0 0); }
}

@keyframes lc-theme-wipe-up {
  from { clip-path: inset(100% 0 0 0); }
  to { clip-path: inset(0); }
}

/* Page navigation keeps a short fade only when a theme curtain is not running. */
html:not([data-lc-theme-dir])::view-transition-old(root) {
  animation-name: lc-vt-fade-out;
  animation-duration: 0.2s;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
}

html:not([data-lc-theme-dir])::view-transition-new(root) {
  animation-name: lc-vt-fade-in;
  animation-duration: 0.2s;
  animation-timing-function: ease-out;
  animation-fill-mode: both;
}

@keyframes lc-vt-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes lc-vt-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

html[data-lc-theme-dir]::view-transition-group(lc-theme-toggle-icon) {
  z-index: 2147483647;
  animation: none;
}

html[data-lc-theme-dir]::view-transition-old(lc-theme-toggle-icon),
html[data-lc-theme-dir]::view-transition-new(lc-theme-toggle-icon) {
  mix-blend-mode: normal;
  height: auto;
  width: auto;
  animation-duration: 500ms;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
}

html[data-lc-theme-dir="to-dark"]::view-transition-old(lc-theme-toggle-icon) {
  animation-name: lc-theme-icon-out-cw;
}

html[data-lc-theme-dir="to-dark"]::view-transition-new(lc-theme-toggle-icon) {
  animation-name: lc-theme-icon-in-cw;
}

html[data-lc-theme-dir="to-light"]::view-transition-old(lc-theme-toggle-icon) {
  animation-name: lc-theme-icon-out-ccw;
}

html[data-lc-theme-dir="to-light"]::view-transition-new(lc-theme-toggle-icon) {
  animation-name: lc-theme-icon-in-ccw;
}

@keyframes lc-theme-icon-out-cw {
  from { opacity: 1; transform: rotate(0deg) scale(1); }
  to { opacity: 0; transform: rotate(90deg) scale(0.5); }
}

@keyframes lc-theme-icon-in-cw {
  from { opacity: 0; transform: rotate(-90deg) scale(0.5); }
  to { opacity: 1; transform: rotate(0deg) scale(1); }
}

@keyframes lc-theme-icon-out-ccw {
  from { opacity: 1; transform: rotate(0deg) scale(1); }
  to { opacity: 0; transform: rotate(-90deg) scale(0.5); }
}

@keyframes lc-theme-icon-in-ccw {
  from { opacity: 0; transform: rotate(90deg) scale(0.5); }
  to { opacity: 1; transform: rotate(0deg) scale(1); }
}

/* Keyboard-focus fallback */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--lc-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

:where(
  input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea
) {
  cursor: text;
}

/* Keyboard: 1px ink ring. Mouse :focus keeps the existing border swap. */
:where(
  input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
  textarea,
  select
):focus-visible {
  outline: 1px solid var(--lc-primary);
  outline-offset: 2px;
}

:is(
  a[href],
  button:not(:disabled),
  summary,
  label[for],
  select,
  [role="button"]:not([aria-disabled="true"]),
  [role="link"],
  [role="tab"],
  input[type="submit"],
  input[type="button"],
  input[type="reset"],
  input[type="checkbox"],
  input[type="radio"]
) {
  cursor: pointer;
}

:is(button:disabled, [aria-disabled="true"]) {
  cursor: not-allowed;
}

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

a {
  text-decoration: none;
  /* color: inherit; */
  transition: color var(--lc-transition), border-color var(--lc-transition);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--lc-font-heading);
  font-weight: 400;
  line-height: 1.25;
  color: var(--lc-on-surface);
  letter-spacing: 0;
  text-wrap: balance;
}

/* Type utilities (legacy semantic classes kept for template compatibility) */
.lc-display-lg {
  font-family: var(--lc-font-display);
  font-size: var(--lc-text-display-lg);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.lc-headline-lg {
  font-family: var(--lc-font-heading);
  font-size: var(--lc-text-headline-lg);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0;
}

.lc-headline-md {
  font-family: var(--lc-font-heading);
  font-size: var(--lc-text-headline-md);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0;
}

.lc-body-lg {
  font-size: var(--lc-text-body-lg);
  line-height: 1.65;
}

.lc-body-md {
  font-size: var(--lc-text-body-md);
  line-height: 1.6;
}

.lc-caption {
  font-family: var(--lc-font-caption);
  font-size: var(--lc-text-caption);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lc-label-md {
  font-family: var(--lc-font-ui);
  font-size: var(--lc-text-label-md);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.lc-muted {
  color: var(--lc-on-surface-variant);
}

.lc-container {
  width: 100%;
  max-width: var(--lc-container-max);
  margin-inline: auto;
  padding-inline: var(--lc-gutter-mobile);
}

@media (min-width: 768px) {
  .lc-container {
    padding-inline: var(--lc-gutter-desktop);
  }
}

/* Phone: drop the outer main gutter so hairline frames go edge-to-edge.
   Nav, page-header, footer, and reading layouts keep --lc-gutter-mobile. */
@media (max-width: 767px) {
  .lc-articles-archive > .mx-auto.max-w-container-max,
  .lc-projects-archive > .mx-auto.max-w-container-max,
  .lc-about-page > .mx-auto.max-w-container-max,
  .lc-404-page > .mx-auto.max-w-container-max,
  .lc-guestbook-page > .mx-auto.max-w-container-max,
  .lc-friend-links-page > .mx-auto.max-w-container-max,
  .lc-contact-page > .mx-auto,
  .lc-front-page > section > .mx-auto.max-w-container-max,
  .lc-project-single > .mx-auto.max-w-container-max,
  .lc-search-form-page {
    padding-inline: 0;
  }
}

.lc-sr-only,
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lc-skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.625rem 1rem;
  background: var(--lc-primary);
  color: var(--lc-on-primary);
  font-family: var(--lc-font-mono);
  font-size: 0.8125rem;
  border: 1px solid var(--lc-primary);
}

.lc-skip-link:focus {
  top: 0.5rem;
}

/* Material symbols icon */
.lc-material-icon {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 1.2rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 1, "wght" 400;
  min-width: 1em;
  min-height: 1em;
  opacity: 0;
  vertical-align: -0.18em;
}

html.lc-icons-ready .lc-material-icon,
html.no-js .lc-material-icon {
  opacity: 1;
  transition: opacity 0.12s ease;
}

.lc-default-content {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
}

/* Activated-link pending state during View Transitions navigation */
.lc-nav-pending {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

body.lc-menu-open {
  overflow: hidden;
}

/* Toast — anchored bottom-left */
.lc-toast-region {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(20rem, calc(100vw - 2rem));
}

.lc-toast {
  padding: 0.625rem 1rem;
  border: 1px solid var(--lc-border-divider);
  background: var(--lc-surface-container-lowest);
  color: var(--lc-on-surface);
  font-family: var(--lc-font-ui);
  font-size: var(--lc-text-body-sm);
  letter-spacing: 0;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.lc-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .lc-toast {
    transition: none;
    transform: none;
  }
}

/* Lazy image reveal — simple opacity fade (no blur, wireframe) */
@media (prefers-reduced-motion: no-preference) {
  img[loading="lazy"]:not(.lc-no-reveal):not(.lc-bento-card__bg-shot):not(.lc-article-card__cover-img):not(.lc-comment-tech__avatar):not(.lc-article__author-avatar) {
    opacity: 0;
    transition: opacity 0.3s var(--lc-ease-out);
  }

  img[loading="lazy"].is-loaded:not(.lc-no-reveal):not(.lc-bento-card__bg-shot):not(.lc-article-card__cover-img):not(.lc-comment-tech__avatar):not(.lc-article__author-avatar) {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  img[loading="lazy"]:not(.lc-no-reveal) {
    opacity: 1;
  }
}

/* Prose bare-link: always-on 1px hairline, hover stays ink */
.lc-article__content a:not([class]),
.lc-prose a:not([class]) {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--lc-outline);
  overflow-wrap: anywhere;
}

.lc-article__content a:not([class]):hover,
.lc-prose a:not([class]):hover {
  text-decoration-color: var(--lc-primary);
}

.lc-article__content a:not([class]):has(> img),
.lc-article__content a:not([class]):has(img),
.lc-prose a:not([class]):has(> img),
.lc-prose a:not([class]):has(img) {
  text-decoration: none;
}

/* Legacy cards: wireframe = hairline border, no radius, no shadow */
.lc-card {
  background: var(--lc-surface-container-lowest);
  border: 1px solid var(--lc-border-divider);
  transition: border-color 0.15s ease;
}

.lc-card--hover:hover {
  border-color: var(--lc-primary);
}

/* Legacy chip — sharp technical tag */
.lc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--lc-border-divider);
  background: var(--lc-surface-container-low);
  font-family: var(--lc-font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
