/* ===== Base / Tokens ===== */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=Playfair+Display:wght@600&display=swap");

@property --tint {
    syntax: '<color>';
    inherits: true;
    initial-value: lavender;
  }
  
  :root {
    --bg: #fffbf7;
    --fg: #111;
    --project-card: #ffffff;
    --accent: #5d5985;
    --brand: #5d5985;
    --header-bg: rgb(172, 207, 172);
    --footer-bg: rgb(172, 207, 172);

    --link-hover: rgb(43, 0, 255);
    --border-subtle: #ccc;
    --input-bg: #ffffff;
    --input-text: #111;
    --placeholder: #888;
  
    --error: #b00020;
    --error-bg: #ffeef0;
    --success: #1a7f37;
    --success-bg: #f0fff5;
    --info: #006400;
    --muted: #555;
  
    --warning: #b36b00;
  }

/* Dark theme overrides */
:root[data-theme="dark"] {
  --bg: #020617;          /* page background */
  --fg: #f9fafb;          /* main text */
  --project-card: #0b1120;        /* cards / form background */
  --accent: #a5b4fc;
  --brand: #818cf8;
  --header-bg: #020617;
  --footer-bg: #020617;

  --link-hover: #a5b4fc;
  --border-subtle: #4b5563;
  --input-bg: #020617;
  --input-text: #e5e7eb;
  --placeholder: #9ca3af;

  --error: #fecaca;
  --error-bg: #450a0a;
  --success: #bbf7d0;
  --success-bg: #064e3b;
  --info: #bfdbfe;
  --muted: #9ca3af;

  --warning: #facc15;

}


* { box-sizing: border-box; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  margin: 0;
}

figcaption {
  justify-content: center;
}

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

a {
  text-decoration: none;
  color: inherit;

  &:hover {
    color: var(--link-hover);
  }
}

/* ===== About Me ===== */
.about-me {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;

  picture { flex: 0 0 150px; }

  img {
    display: block;
    width: 150px;
    height: auto;
    border-radius: 8px;
    padding: 5px;
  }

  portfolio-callout { flex: 1 1 280px; }
}

/* ===== Header (top nav) ===== */
header.main-nav {
  display: grid;
  grid-template-columns: 1fr auto; /* fixed invalid property */
  align-items: center;
  padding: 0.5rem 1rem;
  min-height: 20dvh;

  h1,
  p {
    grid-column: 1;
    margin: 0;
  }

  nav {
    grid-column: 2;
    justify-self: end;
    background-color: transparent;

    ul {
      list-style: none;
      display: flex;
      justify-content: center;
      gap: 1.5rem;
      margin: 0;
      padding: 0;
      border-radius: 8px;

      a {
        text-decoration: none;

        &:hover {
          background-color: lavenderblush;
          color: var(--accent);
          border-radius: 8px;
        }
      }
    }
  }
}

/* ===== Footer ===== */
footer {
  background-color: var(--footer-bg);
  justify-content: center;

  nav {
    background-color: var(--footer-bg);
    justify-content: center;

    ul,
    li {
      list-style: none;
      margin: 0;
      padding: 0;
    }

    ul {
      display: flex;
      gap: 0.75rem;
      justify-content: center;
      align-items: center;
    }

    a img {
      display: block;
      width: 28px;
      height: 28px;
      padding: 4px;
    }
  }
}

/* ===== Status Bar ===== */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  text-align: center;
  margin: 2rem 0;

  h4 { flex-basis: 100%; }

  p { margin: 0; }

  progress {
    accent-color: var(--accent);
    height: 1rem;
    border-radius: 8px;
  }

  .status-gif {
    width: 80px;
    height: auto;
    border-radius: 8px;
  }
}

/* ===== Project Card ===== */
.project-card {
  color: #000; 
  display: flex;
  flex-direction: column;
  background: var(--tint);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform .12s ease, box-shadow .12s ease;
  justify-content: center;
  gap: 20px;
  margin: 0 auto;
  padding: 1rem;
  border-radius: 16px;
  max-width: 80%;

  figure { margin: 12px 0; }

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 22px rgba(0, 0, 0, .12);
    --tint: #f5e9ff;
  }

  img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
  }
}

/* ===== Header & footer color ===== */
.main-nav {
  background-color: var(--header-bg);
}

/* ===== Responsive Design Section ===== */
html {
    overflow-x: hidden; /* Prevent horizontal scrolling on small screens */
  }
  img {
    max-width: 100%; /* Makes sure all images resize properly */
    height: auto;
    display: block;
  }
  
  .container {
    width: min(100% - 2rem, 1100px);
    margin-inline: auto;
  }
  
  /* ===== Navigation (Hamburger Menu) ===== */
  header.main-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
  
    .burger {
      justify-self: end;
      font-size: 1.5rem;
      line-height: 1;
      padding: 0.25rem 0.5rem;
      border-radius: 0.5rem;
      cursor: pointer;
    }
  
    nav {
      /* nav is hidden until the burger is clicked */
      grid-column: 1 / -1;
      display: none;
  
      ul {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
        padding-top: 0.5rem;
  
        a {
          padding: 0.5rem;
          border-radius: 0.5rem;
        }
      }
    }
  
    /* This line makes the menu appear when the checkbox is checked */
    #nav-toggle:checked ~ nav {
      display: block;
    }
  }
  
  /* ===== Layout adjustments for phone (default) ===== */
  .about-me {
    flex-direction: column;
    picture {
      max-width: 200px;
    }
  }
  .posts,
  .projects,
  .projects-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;

    padding: 2rem 5vw;

  }
  
  /* ===== Tablet & Small Laptop (≥700px) ===== */
  @media (min-width: 700px) {
    header.main-nav {
      grid-template-columns: 1fr auto;
  
      .burger {
        display: none; /* Hide burger on tablets and up */
      }
  
      nav {
        display: block; /* Always show nav */
        grid-column: 2;
  
        ul {
          flex-direction: row;
          gap: 1rem;
          padding-top: 0;
        }
      }
    }
  
    /* Makes the About section side-by-side instead of stacked */
    .about-me {
      flex-direction: row;
      picture {
        flex-basis: 160px;
      }
    }
  
    /* Use two columns for project/blog grids */
    .posts,
    .projects {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
  
  /* ===== Desktop (≥1100px) ===== */
  /* This breakpoint is for large laptops and desktops — I add more columns and slight scaling */
  @media (min-width: 1100px) {
    /* Grid expands to 3 columns for large screens */
    .posts,
    .projects {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  
    /* Slightly larger About section image */
    .about-me picture {
      flex-basis: 180px;
    }
  }
  
  /* ===== Image sizing across devices ===== */
  picture img {
    width: 100%;
    height: auto;
    border-radius: 8px;
  }
  
  /* ===== Contact Form (form-no-js.html) ===== */

/* Overall form layout */
form {
  width: 100%;
  max-width: 40rem;
  margin: 2rem auto;
  padding: 1.5rem 1.75rem;
  background-color: var(--project-card);
  border-radius: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Remove default fieldset border and space elements out */
form fieldset {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

form legend {
  font-family: "Playfair Display", system-ui, serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Each label + field block */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Labels stacked above fields */
.form-field label,
form > fieldset > label {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Text inputs and textarea */
input[type="text"],
input[type="email"],
textarea {
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-subtle);
  font: inherit;
  background-color: var(--input-bg);
  color: var(--input-text);
}

/* Make textarea resizable only vertically */
textarea {
  resize: vertical;
  min-height: 6rem;
}

/* Radio and checkbox fields: keep things readable */
.form-field p {
  margin: 0;
  font-weight: 600;
}

.form-field input[type="radio"],
.form-field input[type="checkbox"] {
  margin-right: 0.4rem;
}

/* Submit button styled to match your palette */
button[type="submit"] {
  margin-top: 0.75rem;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background-color: var(--brand);
  color: #fff;
  align-self: flex-start;
}

button[type="submit"]:hover,
button[type="submit"]:focus-visible {
  filter: brightness(1.05);
}

/* Error + info outputs under the fields */
.form-messages {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Reserve a little space even when empty */
.error-message,
.info-message {
  min-height: 1.2rem;
  font-size: 0.9rem;
}

.error-message {
  color: var(--error);
}

.info-message {
  color: var(--info);
}

/* Make sure the form looks good on smaller screens */
@media (max-width: 600px) {
  form {
    margin-inline: 1rem;
    padding: 1.25rem 1rem;
  }
}

/* ===== Contact Form Validation States ===== */

/* Required asterisk */
.required-indicator {
  color: var(--error);
}

/* Placeholder styling so :placeholder-shown works cleanly */
input::placeholder,
textarea::placeholder {
  color: #888;
  opacity: 1;
}

/* Focus: keyboard friendly, high contrast */
input:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Required fields that have been filled and are valid */
input:required:not(:placeholder-shown):valid,
textarea:required:not(:placeholder-shown):valid {
  border-color: var(--success);
  background-color: var(--success-bg);
}

/* Required fields that have been filled but are invalid */
input:required:not(:placeholder-shown):invalid,
textarea:required:not(:placeholder-shown):invalid {
  border-color: var(--error);
  background-color: var(--error-bg);
}

/* Make the email field extra clear when invalid */
input[type="email"]:not(:placeholder-shown):invalid {
  border-color: var(--error);
}

/* Optional: slightly highlight required fields even before interaction */
input:required,
textarea:required {
  border-left-width: 3px;
  border-left-color: var(--accent);
}

/* Keep border widths consistent on valid/invalid so layout does not shift */
input:required:not(:placeholder-shown):valid,
textarea:required:not(:placeholder-shown):valid,
input:required:not(:placeholder-shown):invalid,
textarea:required:not(:placeholder-shown):invalid {
  border-left-width: 3px;
}

/* ===== JS Validation Enhancements (form-with-js.html) ===== */

/* Flash effect when illegal characters are typed */
.flash-error {
  animation: flash-bg 0.15s ease-in-out 0s 2;
}

@keyframes flash-bg {
  0% { background-color: var(--error-bg); }
  100% { background-color: var(--project-card); }
}

/* Character counter under textarea */
.char-counter {
  margin-top: 0.15rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.char-counter.warning {
  color: var(--warning);
}

.char-counter.danger {
  color: var(--error);
  font-weight: 600;
}


/* ===== Theme Toggle Button ===== */

/* Hidden by default; shown only when JS adds .js class */
.theme-toggle {
  display: none;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--fg) 30%, transparent);
  background: transparent;
  color: var(--fg);
  font-size: 0.85rem;
  cursor: pointer;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background-color: color-mix(in srgb, var(--fg) 6%, var(--bg) 94%);
}

/* Only show if JS is enabled */
.js .theme-toggle {
  display: inline-flex;
}

/* Place it nicely in the header */
header.main-nav .theme-toggle {
  justify-self: end;
}


/* ===== View Transition API (MPA cross-fade) ===== */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 300ms;
  animation-timing-function: ease-in-out;
}

/* Optionally control z-order so new page slides "on top" */
::view-transition-old(root) {
  z-index: 0;
}
::view-transition-new(root) {
  z-index: 1;
}

/* Buttons for Project-Cards */
.project-controls {
  display: flex;
  justify-content: center;
  align-items: center;       
  gap: 1rem;
  margin: 2rem 0;
}

.projects-controls button {
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background-color: var(--brand);
  color: white;
  justify-self: center;
}

.projects-controls button:hover {
  filter: brightness(1.08);
}
