/* Base reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: #0f172a; /* slate-900 */
}

/* Theme toggle button */
.theme-toggle {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease, transform 150ms ease;
}

/* Language switcher */
.language-switcher { display:flex; gap: 8px; align-items: center; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,1px,1px);
  white-space: nowrap; border: 0;
}
.lang-select {
  appearance: auto;
  border: 1px solid #0f172a;
  background: #ffffff;
  color: #0f172a;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1.2;
}
.theme-dark .lang-select { background: #0f172a; color: #e5e7eb; border-color: #334155; }
.theme-toggle:hover { background: rgba(255,255,255,0.2); border-color: #fff; }
.theme-toggle:active { transform: translateY(1px); }

/* Dark theme variables and overrides */
.theme-dark body { color: #e5e7eb; background-color: #0b1220; }
.theme-dark header { background: #0b1220 !important; color: #e5e7eb !important; }
.theme-dark .service-button { background: #0f172a; border-color: #1e293b; }
.theme-dark .service-button:hover { background-color: #111827; border-color: #3b82f6; box-shadow: 0 8px 25px rgba(59,130,246,0.15); }
.theme-dark .service-button.active { background: linear-gradient(180deg, #0f172a 0%, #0b1220 100%); box-shadow: 0 6px 20px rgba(59,130,246,0.18); }
.theme-dark .service-button h3 { color: #e5e7eb; }
.theme-dark .service-button p, .theme-dark .expansion-section p, .theme-dark .expansion-section ul { color: #cbd5e1; }
.theme-dark .expansion-section { background: #0f172a; border: none; }
.theme-dark .service-expansion-content { background: #0f172a; border-color: #334155; }
.theme-dark .service-expansion-content h3{ color:white }
.theme-dark .reveal-box, .theme-dark .services-reveal-box { background: #0f172a; border-color: #334155; }
.theme-dark .floating-note { background-color: #0f172a; color: #e5e7eb; border-color: #334155; }
.theme-dark .note-title { color: #e5e7eb; }
.theme-dark .note-summary { color: #cbd5e1; }


/* Envelope: dark mode - white borders (strokes), black fills */
.theme-dark .envelope { color: #ffffff; }
.theme-dark .envelope-svg polygon { fill: #000000 !important; }
.theme-dark .envelope-svg .bottom-flap { fill: black; stroke: #ffffff; }
.theme-dark .envelope-svg .bottom-flap { fill: black; stroke: #ffffff; }

/* Services section: dark theme contrast */
.theme-dark #services-reveal-box .reveal-content h1 { color: #ffffff; }
.theme-dark #services-reveal-box .reveal-content { color: #e5e7eb; }
.theme-dark #services-reveal-box .reveal-content p { color: #cbd5e1; }
.theme-dark #services-reveal-box .reveal-content ul,
.theme-dark #services-reveal-box .reveal-content li { color: #cbd5e1; }
.theme-dark .service-expansion-content h3 { color: #93c5fd; }
.theme-dark .expansion-section h4 { color: #60a5fa; }
.theme-dark .service-button h2 { color: #e5e7eb; }
.theme-dark .service-button p { color: #cbd5e1; }
.theme-dark .service-button ul, .theme-dark .service-button li { color: #94a3b8; }


/* Smooth scroll and offset for fixed header */
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
#note, #skills, #services { scroll-margin-top: 96px; }

/* Header tweaks: keep existing inline styles but ensure top spacing for hero */
header { backdrop-filter: saturate(140%) blur(6px); }

.hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding-top: 96px; /* space for fixed header */
}

.hero-inner {
  text-align: center;
}

.site-title {
  margin: 0 0 32px;
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #111827; /* gray-900 */
  background: linear-gradient(180deg, #111827 0, #0f172a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.envelope {
  display: inline-grid;
  place-items: center;
  color: #0f172a;
  transform: translateZ(0);
  position: relative;
  cursor: pointer;
  width: clamp(260px, 36vw, 460px);
  aspect-ratio: 1 / 1;
}

.envelope-svg {
  width: 70%;
  height: 500px;
  filter: drop-shadow(0 4px 16px rgba(2, 6, 23, 0.15));
  transition: transform 500ms ease;
}

.hero-note {
  margin-top: 8px;
  color: #475569; /* slate-600 */
  font-size: 14px;
}

/* Hover lift with smooth settle (replaces float animation) */
.envelope .envelope-svg {
  transition: transform 280ms cubic-bezier(.22,1,.36,1), filter 280ms cubic-bezier(.22,1,.36,1);
  transform-origin: center center;
  transform-box: fill-box; /* ensure origin is relative to SVG bounds */
}
.envelope:hover .envelope-svg {
  transform: translateY(-8px);
  filter: drop-shadow(0 18px 28px rgba(2,6,23,0.28));
}
/* When open, avoid hover motion to keep interaction stable */
.envelope.open .envelope-svg, .envelope.open:hover .envelope-svg {
  transform: none;
  filter: drop-shadow(0 4px 16px rgba(2, 6, 23, 0.15));
}

/* Dark mode: replace hover shadow with a subtle glow */
.theme-dark .envelope:hover .envelope-svg {
  transform: translateY(-8px);
  filter: drop-shadow(0 0 14px rgba(255,255,255,0.35))
          drop-shadow(0 0 28px rgba(59,130,246,0.25));
}
.theme-dark .envelope.open .envelope-svg,
.theme-dark .envelope.open:hover .envelope-svg {
  transform: none;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.20));
}

/* Gentle idle wiggle while closed */
@keyframes envelope-wiggle {
  0%, 22%, 100% { transform: translate(0, 0) rotate(0deg); }
  4% { transform: translate(0, -3px) rotate(-3.6deg); }
  8% { transform: translate(0, 0) rotate(2.4deg); }
  12% { transform: translate(0, -3px) rotate(-2.4deg); }
  16% { transform: translate(0, 0) rotate(1.2deg); }
}

/* Play wiggle only when not open and not hovered */
.envelope:not(.open):not(:hover) .envelope-svg {
  animation: envelope-wiggle 2.3s ease-in-out infinite;
}

/* While scroll-controlled, pause float and disable transitions so JS can drive state */
/* Legacy scroll-controlled state no longer used */


/* Opening interaction - animate over time */

.envelope .top-flap {
  transform-origin: 110px 25px; /* hinge at top edge */
  transition: transform 550ms cubic-bezier(.2,.3,.2,1);
  transform: rotateX(0deg);
  fill-opacity: 1;
}

.envelope.open .top-flap {
  transform: rotateX(-180deg); /* flip upward */

}


/* Floating note that grows beyond the envelope */
.floating-note {
  position: absolute;
  left: 50%;
  top: 72px; /* seam */
  transform: translate(-50%, 0) scale(0.75);
  width: clamp(220px, 70vw, 600px);
  background: #ffffff;
  border: 2px solid #0f172a;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(2,6,23,.25);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease 400ms, transform 900ms cubic-bezier(.2,.7,.2,1) 300ms;
  padding: 18px 20px;
}

.envelope.open .floating-note {
  opacity: 1;
  transform: translate(-50%, 0px) scale(1);
  pointer-events: auto;
}

/* Reading state: user clicked the note after open */
.envelope.closing .floating-note {
  transform: translate(-50%, 50%) scale(0.75);
  opacity: 0;
  box-shadow: 0 24px 80px rgba(2,6,23,.35);
}


.note-inner { text-align: left; }
.note-title { margin: 0 0 8px; font-size: clamp(18px, 2.4vw, 28px); font-weight: 800; color: #0f172a; }
.note-summary { margin: 0; color: #334155; font-size: clamp(18px, 1.6vw, 16px); line-height: 1.6; }


/* ===== Scroll reveal experiment ===== */
/* skills-trigger removed as we now observe the box directly */

.reveal-box {
  width: clamp(100px, 90vw, 900px);
  transform: translate(0%, 0%) translateX(-100%);
  opacity: 0;
  background: #ffffff;
  border: 2px solid #0f172a;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 18px 60px rgba(2,6,23,.25);
  z-index: 999;
  pointer-events: none;
  margin-left: auto;
  margin-right: auto;
  transition: transform 3000ms cubic-bezier(.2,.7,.2,1), opacity 3000ms ease;
}

.reveal-box.is-visible {
  transform: translate(0%, 0%) translateX(0);
  opacity: 1;
}
/* Ensure the transform context remains at phone widths so the class change animates */
@media (max-width: 430px) {
  .reveal-box { transform: translate(0,0); opacity: 1; transition: none; }
}

.reveal-content {
  font-size: clamp(16px, 2vw, 20px);
  color: #0f172a;
}

/* Skills subheadings (light theme) */
#skills h2 { color: #2563eb; }

/* Skills section: dark theme contrast */
.theme-dark #skills { color: #e5e7eb; }
.theme-dark #skills h1 { color: #ffffff; }
.theme-dark #skills h2 { color: #2563eb; }
.theme-dark #skills p { color: #cbd5e1; }
.theme-dark #skills ul, .theme-dark #skills li { color: #cbd5e1; }
.theme-dark #skills a { color: #93c5fd; }

.section-header{
  padding-top: 50vh;
}

.services-reveal-box{
  width: clamp(100px, 90vw, 1200px);
  /* Clean fade-and-grow intro from center */
  transform: scale(0.85);
  opacity: 0;
  background: #ffffff;
  border: 2px solid #0f172a;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 18px 60px rgba(2,6,23,.25);
  z-index: 999;
  pointer-events: none;
  margin-left: auto;
  margin-right: auto;
  transform-origin: center center;
  will-change: transform, opacity;
  transition: transform 3200ms cubic-bezier(0.22, 1, 0.36, 1), opacity 2000ms ease;
}
.services-reveal-box.is-visible {
  /* Reach original size and full opacity */
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Phone (iPhone portrait ~430px): edge-to-edge services section without borders */
@media (max-width: 430px) {
  .services-reveal-box {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding-left: 12px;
    padding-right: 12px;
  }
  .service-button { border-radius: 10px; }
  .service-expansion-content { border: none; box-shadow: none; }

  /* Skills section container: edge-to-edge without borders */
  .reveal-box {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border: none; /* reset */
    border-radius: 0;
    box-shadow: none;
    padding-left: 12px;
    padding-right: 12px;
  }
  /* Add only top and bottom borders on mobile */
  .reveal-box {
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
  }
  .theme-dark .reveal-box {
    border-top: 1px solid #334155;
    border-bottom: 1px solid #334155;
  }
}

/* Service Button Styles */
.service-button {
  flex: 1;
  padding: 20px;
  border: 1px solid #0f172a;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: box-shadow 200ms ease, transform 200ms ease, border-color 200ms ease, background-color 200ms ease;
  text-align: left;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.service-button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.06);
  border: 1px solid rgba(15,23,42,0.12);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 8px 18px rgba(2,6,23,0.10);
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.service-button:hover {
  border-color: #3b82f6;
  background-color: #f8fafc;
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
  transform: translateY(-3px);
}

.service-button:hover::after { opacity: 0; }

/* Specular glisten highlight */
.service-button::before {
  content: '';
  position: absolute;
  inset: -30%;
  background:
    linear-gradient(20deg,
      rgba(255,255,255,0) 47%,
      rgba(255,255,255,0.55) 50%,
      rgba(255,255,255,0) 53%),
    radial-gradient(120% 60% at 20% 0%, rgba(255,255,255,0.14), rgba(255,255,255,0) 60%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 160ms ease;
  pointer-events: none;
}
.service-button:hover::before { opacity: 0; }

/* Text glow on hover instead of overlay */
.service-button:hover h2 {
  text-shadow: 0 0 12px rgba(59,130,246,0.55), 0 0 2px rgba(59,130,246,0.65);
}
.service-button:hover p,
.service-button:hover li {
  text-shadow: 0 0 8px rgba(59,130,246,0.35);
}

/* Dark theme: white-centric glow for better contrast */
.theme-dark .service-button:hover h2 {
  text-shadow: 0 0 12px rgba(255,255,255,0.7), 0 0 2px rgba(255,255,255,0.8);
}
.theme-dark .service-button:hover p,
.theme-dark .service-button:hover li {
  text-shadow: 0 0 8px rgba(255,255,255,0.5);
}

@media (prefers-reduced-motion: reduce) {
  .service-button::after { transition: opacity 150ms ease; }
}

.service-button.active {
  border-color: #3b82f6;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.18);
}

.service-button h2 {
  margin: 0 0 10px 0;
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-weight: 800; /* pop more */
  color: #0f172a;  /* primary header color (deep slate) */
  letter-spacing: 0.1px;
}

.service-button p {
  margin: 0 0 14px 0;
  color: #334155; /* darker for better readability */
  font-size: clamp(0.95rem, 1.6vw, 1rem);
  line-height: 1.65; /* easier to read */
}

.service-button ul {
  margin: 0 0 16px 0;
  padding-left: 20px;
  color: #475569;
}

.service-button li {
  margin-bottom: 4px;
}

/* removed expansion labels; rely on hover/active effects above */

/* Service Expansion Container */
.service-expansion-container {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid #e2e8f0;
}

.service-expansion-content {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.service-expansion-content h3 {
  margin: 0 0 16px 0;
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  font-weight: 800;
  color: #2563eb; /* accent blue to draw attention */
  text-align: center;
}

/* Services button container */
.services-grid {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .services-grid {
    flex-direction: column;
  }
}

.expansion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

/* When three items wrap to two columns, center the last card on its own row */
@media (min-width: 811px) and (max-width: 1185px) {
  .expansion-grid {
    grid-template-columns: repeat(2, minmax(300px, 1fr));
  }
  .expansion-grid > .expansion-section:last-child {
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 620px;
  }
}

.expansion-section {
  background: #ffffff;
  padding: 24px;
  border-radius: 8px;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.expansion-section h4 {
  margin: 0 0 10px 0;
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  font-weight: 700;
  color: #1d4ed8; /* secondary blue for subheaders */
}

.expansion-section p {
  margin: 0 0 14px 0;
  color: #334155; /* high readability fine text */
  font-size: 1rem;
  line-height: 1.7;
}

.expansion-section ul {
  margin: 0;
  padding-left: 20px;
  color: #475569;
}

.expansion-section li {
  margin-bottom: 6px;
  line-height: 1.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .service-button {
    padding: 16px;
  }
  
  .service-expansion-content {
    padding: 24px;
  }
  
  .expansion-grid {
    grid-template-columns: 1fr;
    gap: 20px; /* consistent spacing between subsections */
    width: 100%;
  }
  
  .expansion-section {
    padding: 20px;
    display: flex;              /* vertically stack content inside each subsection */
    flex-direction: column;
    gap: 10px;                  /* consistent inner spacing */
    align-items: stretch;
  }

  /* normalize inner element spacing */
  .expansion-section > :first-child { margin-top: 0; }
  .expansion-section > :last-child { margin-bottom: 0; }
  .expansion-section h4 { margin-bottom: 6px; }
  .expansion-section p { margin: 0; }
  .expansion-section ul { margin: 6px 0 0 0; padding-left: 20px; }
}

/* Tablet portrait: vertically stack subsections with proper spacing */
@media (min-width: 769px) and (max-width: 810px) {
  .expansion-grid {
    grid-template-columns: 1fr;   /* stack the three subsections */
    gap: 24px;                    /* comfortable spacing between them */
    width: 100%;
  }
  .expansion-section {
    display: flex;
    flex-direction: column;
    gap: 12px;                    /* consistent inner spacing */
    align-items: stretch;
  }
  .expansion-section > :first-child { margin-top: 0; }
  .expansion-section > :last-child { margin-bottom: 0; }
  .expansion-section h4 { margin-bottom: 6px; }
  .expansion-section p { margin: 0; }
  .expansion-section ul { margin: 6px 0 0 0; padding-left: 20px; }
}

/* Accordion behavior toggled by layout (vertical stack) */
.services-reveal-box.accordion-mode .service-button > ul { display: none; }
.services-reveal-box.accordion-mode .service-expansion-container { display: none; }
.services-reveal-box.accordion-mode .service-button .accordion-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  transition: max-height 400ms ease, opacity 300ms ease, transform 300ms ease;
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
  padding-top: 0;
}
.services-reveal-box.accordion-mode .service-button.accordion-open .accordion-panel {
  opacity: 1;
  transform: translateY(0);
  max-height: 1200px;
}

/* Keep subsections' layout consistent with tab alignment */
.services-reveal-box.accordion-mode .accordion-panel .expansion-grid {
  display: grid;
  grid-template-columns: 1fr; /* vertical stack when tabs are vertical */
  gap: 20px;
}

/* =====================
   Auth/Login styles
   ===================== */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border: 1px solid #0f172a;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 18px 60px rgba(2,6,23,.15);
}

.auth-title {
  margin: 0 0 16px 0;
  text-align: center;
}

.auth-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #0f172a;
  border-radius: 10px; /* rounded edges */
  font: inherit;
  background: #ffffff;
}
.auth-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}

/* Button styled like services tabs */
.auth-button {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #0f172a; /* same base border */
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  transition: box-shadow 200ms ease, transform 200ms ease, border-color 200ms ease, background-color 200ms ease;
  font: inherit;
  font-weight: 700;
}
.auth-button:hover {
  border-color: #3b82f6;
  background-color: #f8fafc;
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
}
.auth-button:active {
  transform: translateY(0);
}

/* Dark theme parity */
.theme-dark .auth-card { background: #0f172a; border-color: #334155; box-shadow: 0 8px 25px rgba(59,130,246,0.15); }
.theme-dark .auth-input { background: #0b1220; color: #e5e7eb; border-color: #334155; }
.theme-dark .auth-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
.theme-dark .auth-button { background: #0f172a; border-color: #1e293b; color: #e5e7eb; }
.theme-dark .auth-button:hover { background-color: #111827; border-color: #3b82f6; box-shadow: 0 8px 25px rgba(59,130,246,0.15); }