@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap");

/* ------------------------------
   DESIGN TOKENS
--------------------------------*/
:root {
  --brand: #0b57d0;
  --brand-contrast: #fff;
  --text: #161616;
  --muted: #666;
  --surface: #f7f7f9;
  --radius: 14px;

  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: clamp(1.6rem, 1rem + 2.5vw, 2.4rem);

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;

  --brand-soft: color-mix(in oklab, var(--brand) 70%, white);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  view-transition-name: root;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--text, #111);
  background: var(--surface, #fafafa);
  line-height: 1.6;
  font-size: var(--fs-base);
}

/* wrapper grid for pages that use it */
.wrapper {
  display: grid;
  grid-template-columns: 1fr min(1100px, 92dvw) 1fr;
  flex: 1;
}

.wrapper > * {
  grid-column: 2;
}

/* ------------------------------
   HEADER / NAV
--------------------------------*/
.site-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) clamp(1rem, 2vw, 2rem);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: var(--brand-contrast);
}

.brand {
  font-weight: 600;
  font-size: clamp(1.125rem, 0.9rem + 1.5vw, 1.6rem);
  letter-spacing: 0.2px;
}

.nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  gap: clamp(0.5rem, 2vw, 1rem);
}

.nav a {
  color: inherit;
  text-decoration: none;
  padding: 0.45em 0.75em;
  border-radius: 999px;
  transition: transform 160ms ease, background-color 160ms ease;
}

.nav a:hover,
.nav a:focus-visible {
  background: var(--brand-soft);
  transform: translateY(-1px);
}

/* ------------------------------
   FOOTER
--------------------------------*/
.site-footer {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-3) clamp(1rem, 2vw, 2rem);
  background: var(--brand);
  color: #fff;
}

/* ------------------------------
   HERO & SECTIONS
--------------------------------*/
.hero {
  min-height: 60dvh;
  display: grid;
  place-items: center;
  padding: var(--space-4) var(--space-2);
  text-align: center;
  animation: fade-in 600ms ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

main > section {
  background: #fff;
  border-radius: var(--radius);
  padding: var(--space-3);
  margin: var(--space-3) 0;
  box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.25);
}

/* ------------------------------
   CARDS / PROJECTS
--------------------------------*/
.projects-list {
  --min: 260px;
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(var(--min), 1fr));
  margin-block: var(--space-2);
}

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: var(--space-2);
  box-shadow: 0 8px 18px -14px rgba(0, 0, 0, 0.25);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.3);
}

.card h3 {
  margin: 0 0 0.25em;
  font-size: var(--fs-xl);
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-lg);
}

/* ------------------------------
   MEDIA / GALLERY
--------------------------------*/
img {
  max-width: 100%;
  height: auto;
}

.media-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
}

.media-frame > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Scoped gallery styles (modern CSS) */
@scope (.gallery) {
  :scope {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-2);
    margin-block: var(--space-3);
  }

  img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius);
  }
}

/* Optional helper element */
layout-block {
  display: block;
  text-align: center;
  padding: 1rem;
  font-style: italic;
  color: var(--muted, #444);
  opacity: 0.85;
}

/* ------------------------------
   CONTACT FORM (form-no-js / with-js)
--------------------------------*/

/* Card */
.form-wrapper {
  width: min(100%, 540px);
  margin: 4rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 30px -16px rgba(0, 0, 0, 0.35);
}

/* Layout */
.form-wrapper form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Label + stack */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

/* Labels */
.form-field label {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Inputs */
input,
textarea,
button {
  font: inherit;
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid #d7d7db;
  background: #fff;
  transition: border-color 150ms ease, background-color 150ms ease;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #a0a0aa;
}

/* Focus */
input:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

/* Hover */
input:hover,
textarea:hover {
  border-color: #c4c4cf;
}

/* ------------------------------
   PART 2 VALIDATION STATES
--------------------------------*/

/* Required indicator */
input:required,
textarea:required {
  border-left: 3px solid #e5e7eb;
}

/* Invalid state */
input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
  border-color: #dc2626;
  border-left-color: #dc2626;
  background: #fef2f2;
}

/* Valid state */
input:valid:not(:placeholder-shown),
textarea:valid:not(:placeholder-shown) {
  border-color: #16a34a;
  border-left-color: #16a34a;
}

/* Submit button */
button[type="submit"] {
  align-self: flex-start;
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  background: var(--brand);
  color: var(--brand-contrast);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -12px
    color-mix(in oklab, var(--brand) 50%, transparent);
}

/* Output */
.form-output {
  display: block;
  min-height: 1.2rem;
  font-size: 0.9rem;
}

.form-output.error {
  color: #b91c1c;
}

.form-output.info {
  color: var(--brand);
}

/* ------------------------------
   PART 3 HELPERS (JS validation)
--------------------------------*/

/* Flash animation for illegal characters */
.field-flash {
  animation: field-flash 0.15s ease-in-out 0s 2;
}

@keyframes field-flash {
  from {
    background-color: #fef2f2;
  }
  to {
    background-color: #fff;
  }
}

/* Character counter under textarea */
.char-remaining {
  display: block;
  font-size: 0.8rem;
  color: #6b7280;
  text-align: right;
  margin-top: 0.15rem;
}

.char-remaining--warn {
  color: #b45309;
}

.char-remaining--over {
  color: #b91c1c;
  font-weight: 600;
}

/* ------------------------------
   RESPONSIVE TWEAKS
--------------------------------*/
@media (min-width: 600px) {
  .hero {
    min-height: 65dvh;
  }
}

@media (min-width: 900px) {
  .site-header {
    padding: var(--space-2) var(--space-4);
  }
  .hero {
    min-height: 70dvh;
  }
}

/* ------------------------------
   THEME TOGGLE (Part 4.1)
--------------------------------*/

/* Hide [hidden] elements (for toggle before JS) */
[hidden] {
  display: none !important;
}

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

/* Theme toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: transparent;
  color: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: var(--brand-soft, rgba(255, 255, 255, 0.1));
  transform: translateY(-1px);
}

/* Noscript message */
.noscript-note {
  margin: 0;
  padding: 0.5rem 1rem;
  text-align: center;
  background: #f97316;
  color: #111827;
  font-size: 0.9rem;
}

/* ------------------------------
   DARK THEME OVERRIDES
   (html[data-theme="dark"])
--------------------------------*/

html[data-theme="dark"] {
  color-scheme: dark;
  --brand: #60a5fa;
  --brand-contrast: #020617;
  --text: #f9fafb;
  --muted: #9ca3af;
  --surface: #020617;
}

/* Dark body background */
html[data-theme="dark"] body {
  background: #020617;
}

/* Cards / sections / form wrapper in dark */
html[data-theme="dark"] .form-wrapper,
html[data-theme="dark"] main > section,
html[data-theme="dark"] .card {
  background: #111827;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.9);
}

/* Header + footer */
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .site-footer {
  background: #020617;
  color: #e5e7eb;
}

/* Inputs in dark mode */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] textarea {
  background: #020617;
  border-color: #4b5563;
  color: #e5e7eb;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #6b7280;
}

/* Submit button in dark mode */
html[data-theme="dark"] button[type="submit"] {
  background: #2563eb;
  color: #f9fafb;
}