/* ============================================================
           Liquid Glass — Design Tokens (v2)
           Variable naming: --lg-{group}-{subgroup}-{token}
           ============================================================ */

:root {
  /* --- Glass Physics (canonical) --- */
  --lg-glass-blur: 20px;
  --lg-glass-bg-opacity: 0.12;
  --lg-glass-border-opacity: 0.2;
  --lg-glass-surface: rgba(255, 255, 255, var(--lg-glass-bg-opacity));
  --lg-glass-border: rgba(255, 255, 255, var(--lg-glass-border-opacity));
  --lg-glass-reflection: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0) 60%,
    rgba(255, 255, 255, 0.15) 100%
  );
  --lg-glass-easing: cubic-bezier(0.32, 0.72, 0, 1);
  --lg-glass-transition-duration: 400ms;
  --lg-glass-transition: var(--lg-glass-transition-duration)
    var(--lg-glass-easing);
  --lg-glass-shadow-soft: 0 20px 50px rgba(0, 0, 0, 0.1);
  --lg-glass-shadow-sharp: 0 1px 2px rgba(0, 0, 0, 0.05);

  /* --- Palette: Primary --- */
  --lg-palette-primary-main: #18181b;
  --lg-palette-primary-dark: #09090b;
  --lg-palette-primary-light: #3f3f46;

  /* --- Palette: Text --- */
  --lg-palette-text-primary: #18181b;
  --lg-palette-text-secondary: #52525b;
  --lg-palette-text-disabled: rgba(0, 0, 0, 0.38);
  --lg-palette-text-on-surface: #fff;
  --lg-palette-text-on-surface-secondary: #d4d4d8;

  /* --- Palette: Background --- */
  --lg-palette-background-default: #fff;
  --lg-palette-background-paper: #fff;
  --lg-palette-background-fallback: linear-gradient(
    135deg,
    #09090b 0%,
    #18181b 25%,
    #27272a 50%,
    #3f3f46 75%,
    #52525b 100%
  );

  /* --- Typography --- */
  --lg-typography-font-family: system-ui, -apple-system, sans-serif;
}

/* --- Dark mode token overrides --- */
@media (prefers-color-scheme: dark) {
  :root {
    --lg-glass-surface: rgba(0, 0, 0, 0.35);
    --lg-glass-border: rgba(255, 255, 255, 0.1);
    --lg-glass-bg-opacity: 0.35;
    --lg-palette-text-primary: #f4f4f5;
    --lg-palette-text-secondary: #a1a1aa;
  }
}

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --lg-glass-transition-duration: 0ms;
  }

  html,
  body,
  .scrollable {
    scroll-behavior: auto;
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --lg-glass-bg-opacity: 0.98;
    --lg-glass-blur: 0px;
  }
}

* {
  box-sizing: border-box;
}

/* Reset default margins and paddings */
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  font-family: var(--lg-typography-font-family);
  min-height: 100vh;
  color: var(--lg-palette-text-primary);
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
    url("./assets/background-image-profile.jpeg"),
    var(--lg-palette-background-fallback);
  background-size: auto 100vh;
  background-position: right;
  background-repeat: no-repeat;
  will-change: transform;
  pointer-events: none;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  pointer-events: none;
  /* background: var(--lg-palette-surface, transparent); */
}

header * {
  pointer-events: auto;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
}

nav a {
  color: var(--lg-palette-text-on-surface-secondary);
  text-decoration: none;
  cursor: pointer;
  padding: 0 8px;
}

nav a:hover {
  opacity: 0.8;
}

.portfolio-container,
.demo-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.portfolio-section,
.demo-section {
  margin-bottom: 48px;
}

.portfolio-title,
.demo-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--lg-palette-text-on-surface);
}

/* Card — Regular elevation glass */
.card {
  position: relative;
  background: var(--lg-glass-surface);
  backdrop-filter: blur(var(--lg-glass-blur));
  -webkit-backdrop-filter: blur(var(--lg-glass-blur));
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--lg-glass-shadow-soft), var(--lg-glass-shadow-sharp);
  transition:
    box-shadow var(--lg-glass-transition),
    transform var(--lg-glass-transition);
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--lg-glass-reflection);
  pointer-events: none;
}

.card-elevated {
  position: relative;
  background: var(--lg-glass-surface);
  backdrop-filter: blur(var(--lg-glass-blur));
  -webkit-backdrop-filter: blur(var(--lg-glass-blur));
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--lg-glass-shadow-soft), var(--lg-glass-shadow-sharp);
  transition:
    box-shadow var(--lg-glass-transition),
    transform var(--lg-glass-transition);
  border: 1px solid var(--lg-glass-border);
}

.card-elevated::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--lg-glass-reflection);
  pointer-events: none;
}

.content {
  position: relative;
  z-index: 1;
  padding: 16px;
}

.content:last-child {
  padding-bottom: 24px;
}

.media {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  object-fit: cover;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

/* Typography styles */
h3 {
  margin: 0 0 8px 0;
  font-size: clamp(18px, 4vw, 20px);
  font-weight: 600;
  color: var(--lg-palette-text-on-surface);
}

p {
  margin: 0 0 12px 0;
  font-size: clamp(13px, 3vw, 14px);
  line-height: 1.5;
  color: var(--lg-palette-text-on-surface-secondary);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--lg-glass-border);
  background: var(--lg-glass-surface);
  color: var(--lg-palette-text-on-surface-secondary);
  font-size: clamp(12px, 2.5vw, 14px);
  cursor: pointer;
  transition: all var(--lg-glass-transition);
}

.button:hover {
  background: var(--lg-palette-action-hover);
}

.button:active {
  transform: scale(0.95);
}

/* Prevent the body itself from scrolling */
body.layout-fullscreen {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}

@media (min-width: 769px) {
  body.layout-fullscreen {
    padding: 20px 40px;
  }
}

/* Body padding for non-fullscreen layouts */
body:not(.layout-fullscreen) {
  padding: 20px 40px;
}

/* Container: Use Flex to center the card without forcing its shape */
.layout-hero.portfolio-container {
  min-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.layout-hero .portfolio-section {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100%;
  min-height: 0;
}

.layout-hero .card {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 160px);
  width: fit-content;
  max-width: 100%;

  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  margin: 0 auto;
}

.layout-hero .card .media {
  flex: 1;
  width: auto;
  max-width: 100%;
  height: 100%;
  min-height: 0;

  object-fit: cover;
  object-position: top;
}

.layout-hero .card .content {
  flex: 0 0 auto;
  width: 100%;
  padding: 20px;
  background: var(--lg-glass-surface);
}

.layout-hero .card p {
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;

  a {
    color: var(--lg-palette-text-on-surface);
  }
}

.layout-hero .card-actions {
  margin-top: 8px;
  flex-shrink: 0;
}

/* Layout List (e.g. About page) */
.layout-list,
.demo-container.layout-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* Portfolio Links */
.portfolio-links {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.portfolio-links a {
  text-decoration: none;
  display: block;
}

.portfolio-links a:hover {
  opacity: 0.8;
}

.portfolio-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-title {
  font-weight: 600;
  font-size: clamp(18px, 3.5vw, 20px);
  color: var(--lg-palette-text-on-surface-secondary);
}

.portfolio-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portfolio-description {
  color: var(--lg-palette-text-on-surface-secondary);
  font-size: clamp(14px, 2.5vw, 16px);
  line-height: 1.5;
  margin: 0;
  padding: 0 16px;
}

.layout-list .portfolio-section,
.demo-container.layout-list .demo-section {
  width: 100%;
  margin-bottom: 0;
  padding-bottom: 20px;
}

/* Desktop-specific positioning for demo-container */
@media (min-width: 769px) {
  .demo-container.layout-list {
    width: 45%;
    margin-left: 5%;
    margin-right: auto;
  }
}

.layout-list .portfolio-section:last-child,
.demo-container.layout-list .demo-section:last-child {
  padding-bottom: 0;
}

.scrollable {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 1; /* In front of background (-1), behind header (10) */
  padding-top: 120px; /* Space for the header */
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  padding-bottom: 40px; /* Give some breathing room at the bottom */
}

/* Hide scrollbar for WebKit browsers */
.scrollable::-webkit-scrollbar {
  display: none;
}

.layout-list .card,
.demo-container.layout-list .card {
  width: 100%;
}

.desktop {
  display: block;
}

.mobile {
  display: none;
}

/* === Mobile Responsiveness --- */
@media (max-width: 768px) {
  html {
    background-color: var(--lg-palette-primary-dark);
    height: auto;
  }

  body {
    height: auto;
  }

  body::before {
    background-size: cover;
  }

  .desktop {
    display: none;
  }

  .mobile {
    display: block;
  }
  body:not(.layout-fullscreen) {
    padding: 16px;
  }

  body.layout-fullscreen {
    padding: 0;
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }

  header {
    flex-direction: column;
    padding: 1rem;
    gap: 16px;
  }

  .scrollable {
    position: static;
    height: auto;
    overflow-y: visible;
    padding-top: 0;
    padding-left: 16px;
    padding-right: 16px;
  }

  nav {
    width: 100%;
    justify-content: center;
  }

  .demo-title {
    font-size: 24px;
    text-align: center;
  }

  .layout-hero.portfolio-container {
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 10px 0;
  }

  .layout-hero .card {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 180px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
  }

  .layout-hero .card .media {
    height: 25vh;
    min-height: 120px;
    flex: none;
    object-position: center 20%;
  }

  .layout-hero .card .content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
  }

  .layout-hero .card p {
    -webkit-line-clamp: unset;
    line-clamp: none;
    font-size: 16px;
    line-height: 1.6;
  }

  .layout-hero .card h3 {
    font-size: 24px;
    margin-bottom: 12px;
  }

  .layout-hero .card .button {
    font-size: 16px;
    padding: 12px 20px;
  }

  .layout-hero .card-actions {
    flex-wrap: wrap;
    gap: 12px;
  }

  .layout-hero .card-actions a,
  .layout-list .card-actions a {
    width: 100%;
  }

  .layout-hero .card-actions .button,
  .layout-list .card-actions .button {
    width: 100%; /* Make buttons full width on mobile for better tap targets */
  }

  .portfolio-container,
  .demo-container.layout-list,
  .demo-container {
    grid-template-columns: 1fr;
    width: 100%;
    margin: 0 auto;
  }
}

/* === Landscape Mobile Responsiveness --- */
@media (max-height: 500px) and (orientation: landscape) {
  html {
    background-color: var(--lg-palette-primary-dark);
    height: auto;
  }

  body {
    height: auto;
  }

  body::before {
    background-size: cover;
  }

  body.layout-fullscreen {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    padding: 0;
  }
}

.speed-dial {
  display: inline-flex;
  align-items: center;
  position: relative;
  gap: 16px;
  flex-direction: column-reverse;
  --sd-closed-translate: translateY(16px);
}

.fab {
  /* Reset */
  outline: 0;
  border: 0;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  /* Size */
  width: 56px;
  height: 56px;
  border-radius: 50%;
  /* Typography */
  font-family: var(--lg-typography-font-family);
  font-weight: 500;
  font-size: 0.875rem;
  /* Glass — Thick elevation */
  color: var(--lg-palette-text-on-surface);
  --lg-glass-bg-opacity: 0.25;
  background: var(--lg-glass-surface);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--lg-glass-border);
  box-shadow:
    var(--lg-glass-shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition:
    box-shadow var(--lg-glass-transition),
    transform var(--lg-glass-transition),
    background var(--lg-glass-transition);
}

.fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--lg-glass-reflection);
  pointer-events: none;
}

.fab:hover {
  --lg-glass-bg-opacity: 0.35;
  --lg-glass-border-opacity: 0.4;
  box-shadow:
    var(--lg-glass-shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.fab:active {
  transform: scale(0.97);
}

.fab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--lg-glass-border);
}

/* === FAB Icons === */
.fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  transition:
    opacity var(--lg-glass-transition),
    transform var(--lg-glass-transition);
}

.fab-icon.visible {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.fab-icon.hidden {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
  pointer-events: none;
}

/* === Actions Container === */
.actions {
  display: flex;
  flex-direction: inherit;
  align-items: center;
  gap: 16px;
  opacity: 1;
  transform: translate(0, 0);
  transition:
    opacity var(--lg-glass-transition),
    transform var(--lg-glass-transition);
}

/* Hidden state - controlled by checkbox */
.speed-dial-toggle:not(:checked) ~ .speed-dial .actions {
  opacity: 0;
  transform: var(--sd-closed-translate, translateY(16px));
  pointer-events: none;
}

/* === Action Wrapper === */
.action-wrapper {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* === Action Button === */
.action {
  /* Reset */
  outline: 0;
  border: 0;
  cursor: pointer;
  user-select: none;
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  /* Size */
  width: 40px;
  height: 40px;
  border-radius: 50%;
  /* Glass — Regular elevation */
  color: var(--lg-palette-text-on-surface);
  --lg-glass-bg-opacity: 0.12;
  background: var(--lg-glass-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--lg-glass-border);
  box-shadow: var(--lg-glass-shadow-soft);
  transition:
    transform var(--lg-glass-transition),
    box-shadow var(--lg-glass-transition),
    opacity var(--lg-glass-transition),
    background var(--lg-glass-transition);
}

.action::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--lg-glass-reflection);
  pointer-events: none;
}

.action:hover {
  --lg-glass-bg-opacity: 0.25;
  --lg-glass-border-opacity: 0.4;
  box-shadow:
    var(--lg-glass-shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.action:active {
  transform: scale(0.97);
}

.action:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--lg-glass-border);
}

/* Hidden state - controlled by checkbox */
.speed-dial-toggle:not(:checked) ~ .speed-dial .action {
  opacity: 0;
  transform: scale(0);
}

/* === Checkbox Hack === */
.speed-dial-toggle {
  display: none;
}

/* === SpeedDial Position === */
.speed-dial-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
}

/* === Accessibility === */
@media (prefers-reduced-transparency: reduce) {
  .action,
  .fab {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    --lg-glass-bg-opacity: 0.98;
  }
}

@media (prefers-reduced-motion: reduce) {
  .speed-dial * {
    --lg-glass-transition-duration: 0ms !important;
  }
}

/* === Mobile SpeedDial Override === */
@media (max-width: 768px) {
  .speed-dial {
    flex-direction: row-reverse !important;
    --sd-closed-translate: translateX(-16px) !important;
  }
}

/* === AboutApp Component === */
.about-app {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 1200;
}

.about-app-toggle {
  display: none;
}

.about-app-trigger {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 150ms ease,
    border-color 150ms ease;
  user-select: none;
}

.about-app-trigger:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.7);
}

.about-app-toggle:checked + .about-app-trigger {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.7);
}

.about-app-popover {
  position: fixed;
  bottom: 52px;
  left: 48px;
  z-index: 1200;
  width: 300px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow:
    0 2px 4px -1px rgba(0, 0, 0, 0.2),
    0 4px 5px 0px rgba(0, 0, 0, 0.14),
    0 1px 10px 0px rgba(0, 0, 0, 0.12);
  padding: 16px;
  font-size: 0.8rem;
  color: var(--lg-palette-text-primary);
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity 150ms ease,
    visibility 150ms ease,
    transform 150ms ease;
  pointer-events: none;
}

.about-app-toggle:checked ~ .about-app-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.about-app-copyright {
  font-weight: 600;
  margin-bottom: 10px;
}

.about-app-version {
  font-size: 0.7rem;
  color: var(--lg-palette-text-secondary);
  margin-bottom: 10px;
}

.about-app-divider {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  margin: 10px 0;
}

.about-app-creditsTitle {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--lg-palette-text-secondary);
}

.about-app-credit {
  margin-bottom: 4px;
  font-size: 0.75rem;
  color: var(--lg-palette-primary-main);
}

.about-app-credit a {
  color: var(--lg-palette-primary-main);
  text-decoration: none;
}

.about-app-credit a:hover {
  text-decoration: underline;
}

/* === AboutApp Mobile Responsiveness === */
@media (max-width: 768px) {
  .about-app-popover {
    width: 280px;
    left: 16px;
  }
}
