/* ============================================================
   style.css — rawaha.io
   Accessibility-first personal website
   ============================================================ */

/* ---- OpenDyslexic font (loaded on demand via .dyslexia-font) ------ */
@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("https://cdn.jsdelivr.net/gh/antijingoist/opendyslexic@master/compiled/OpenDyslexic-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   Design tokens — light theme (default)
   All contrast ratios verified ≥ 4.5:1 (WCAG AA) for normal text.
============================================================ */
:root,
[data-theme="light"] {
  --color-bg:            #ffffff;
  --color-bg-alt:        #f4f4f8;
  --color-bg-card:       #ffffff;
  --color-text:          #1a1a2e;
  --color-text-subtle:   #4a4a6a;
  --color-text-inverted: #ffffff;
  --color-accent:        #3d5af1;  /* 5.1:1 on white */
  --color-accent-hover:  #2b46d9;
  --color-accent-subtle: #eef0ff;
  --color-border:        #d0d0e0;
  --color-focus:         #3d5af1;

  /* Badge colours — AA on their respective backgrounds */
  --color-badge-ai-bg:    #ffe8f0;
  --color-badge-ai-text:  #9e0035;   /* 5.8:1 on #ffe8f0 */
  --color-badge-a11y-bg:  #e6f4ea;
  --color-badge-a11y-text:#1a6630;   /* 5.2:1 on #e6f4ea */

  --shadow-card:       0 2px 8px rgba(0,0,0,.07);
  --shadow-card-hover: 0 6px 20px rgba(0,0,0,.13);
  --shadow-dialog:     0 8px 40px rgba(0,0,0,.18);

  --transition-fast: 0.15s ease;
  --transition-med:  0.25s ease;
}

/* ============================================================
   Dark theme
============================================================ */
[data-theme="dark"] {
  --color-bg:            #0d0d1a;
  --color-bg-alt:        #141428;
  --color-bg-card:       #181830;
  --color-text:          #e8e8f2;
  --color-text-subtle:   #9898b8;
  --color-text-inverted: #0d0d1a;
  --color-accent:        #7b93ff;   /* 5.3:1 on #0d0d1a */
  --color-accent-hover:  #9aadff;
  --color-accent-subtle: #1a2045;
  --color-border:        #2a2a48;
  --color-focus:         #9aadff;

  --color-badge-ai-bg:    #3a001a;
  --color-badge-ai-text:  #ff8fb0;  /* 6.2:1 on #3a001a */
  --color-badge-a11y-bg:  #0a2810;
  --color-badge-a11y-text:#7ddb93;  /* 6.8:1 on #0a2810 */

  --shadow-card:       0 2px 8px rgba(0,0,0,.4);
  --shadow-card-hover: 0 6px 20px rgba(0,0,0,.6);
  --shadow-dialog:     0 8px 40px rgba(0,0,0,.7);
}

/* ============================================================
   High-contrast theme — all text ≥ 7:1 (WCAG AAA)
============================================================ */
[data-theme="high-contrast"] {
  --color-bg:            #000000;
  --color-bg-alt:        #000000;
  --color-bg-card:       #000000;
  --color-text:          #ffffff;
  --color-text-subtle:   #ffffff;
  --color-text-inverted: #000000;
  --color-accent:        #ffff00;  /* 19.6:1 on black */
  --color-accent-hover:  #ffff66;
  --color-accent-subtle: #1a1a00;
  --color-border:        #ffffff;
  --color-focus:         #ffff00;

  --color-badge-ai-bg:    #000000;
  --color-badge-ai-text:  #ff9900;  /* 8.3:1 on black */
  --color-badge-a11y-bg:  #000000;
  --color-badge-a11y-text:#00ff66;  /* 12.6:1 on black */

  --shadow-card:       none;
  --shadow-card-hover: none;
  --shadow-dialog:     none;
}

/* ============================================================
   Auto theme: mirror OS dark-mode preference
   Only active when no data-theme attribute is set.
============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:            #0d0d1a;
    --color-bg-alt:        #141428;
    --color-bg-card:       #181830;
    --color-text:          #e8e8f2;
    --color-text-subtle:   #9898b8;
    --color-text-inverted: #0d0d1a;
    --color-accent:        #7b93ff;
    --color-accent-hover:  #9aadff;
    --color-accent-subtle: #1a2045;
    --color-border:        #2a2a48;
    --color-focus:         #9aadff;

    --color-badge-ai-bg:    #3a001a;
    --color-badge-ai-text:  #ff8fb0;
    --color-badge-a11y-bg:  #0a2810;
    --color-badge-a11y-text:#7ddb93;

    --shadow-card:       0 2px 8px rgba(0,0,0,.4);
    --shadow-card-hover: 0 6px 20px rgba(0,0,0,.6);
    --shadow-dialog:     0 8px 40px rgba(0,0,0,.7);
  }
}

/* Honour OS high-contrast (no-JS fallback) */
@media (prefers-contrast: more) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-bg:            #000000;
    --color-bg-alt:        #000000;
    --color-bg-card:       #000000;
    --color-text:          #ffffff;
    --color-text-subtle:   #ffffff;
    --color-text-inverted: #000000;
    --color-accent:        #ffff00;
    --color-accent-hover:  #ffff66;
    --color-accent-subtle: #1a1a00;
    --color-border:        #ffffff;
    --color-focus:         #ffff00;
    --color-badge-ai-bg:    #000000;
    --color-badge-ai-text:  #ff9900;
    --color-badge-a11y-bg:  #000000;
    --color-badge-a11y-text:#00ff66;
    --shadow-card:       none;
    --shadow-card-hover: none;
    --shadow-dialog:     none;
  }
}

/* ============================================================
   Reset & base
============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 100%; /* respect user browser font-size setting */
}

/* No-JS or OS reduced-motion fallback */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* JS-controlled reduced-motion (user toggled via settings) */
html[data-reduced-motion] {
  scroll-behavior: auto !important;
}

html[data-reduced-motion] *,
html[data-reduced-motion] *::before,
html[data-reduced-motion] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.75;
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-med), color var(--transition-med);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}

/* Dyslexia-friendly font toggle */
body.dyslexia-font {
  font-family: "OpenDyslexic", "Comic Sans MS", cursive;
  letter-spacing: 0.05em;
  word-spacing: 0.12em;
  line-height: 1.9;
}

/* ============================================================
   Screen-reader only utility
============================================================ */
.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;
}

/* ============================================================
   Skip link
============================================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  padding: 0.75rem 1.5rem;
  background: var(--color-accent);
  color: var(--color-text-inverted);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 0 0 0.5rem 0.5rem;
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
}

/* ============================================================
   Focus styles — visible on keyboard, hidden on mouse/touch
============================================================ */
:focus { outline: none; }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ============================================================
   Layout
============================================================ */
.container {
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 5vw, 3rem);
}

/* ============================================================
   Header
============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-med);
}

@media (prefers-reduced-motion: reduce) {
  .site-header { transition: none; }
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 5vw, 3rem);
  padding-block: 1rem;
}

/* Logo */
.site-logo {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--color-accent);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.site-logo:hover { color: var(--color-accent-hover); }

/* Nav */
.main-nav ul {
  display: flex;
  list-style: none;
  gap: clamp(0.75rem, 3vw, 2rem);
}

.main-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding-block: 0.25rem;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

@media (prefers-reduced-motion: reduce) {
  .main-nav a { transition: none; }
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* Settings button */
.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .settings-btn { transition: none; }
}

.settings-btn:hover {
  background: var(--color-accent);
  color: var(--color-text-inverted);
}

/* ============================================================
   Sections
============================================================ */
.section {
  padding-block: clamp(4rem, 8vw, 7rem);
}

.section--alt {
  background: var(--color-bg-alt);
}

.section--hero {
  background: var(--color-bg);
  min-height: 85vh;
  display: flex;
  align-items: center;
}

/* Section title */
.section-title {
  font-size: clamp(1.75rem, 3vw + 0.5rem, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--color-text);
  margin-bottom: 2.5rem;
}

.section-title::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  background: var(--color-accent);
  margin-top: 0.5rem;
  border-radius: 2px;
}

/* ============================================================
   Hero
============================================================ */
.hero-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(2rem, 6vw, 5rem);
  flex-wrap: wrap;
}

.hero-content {
  flex: 1 1 340px;
  max-width: 620px;
}

.hero-portrait {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-img {
  width: clamp(180px, 28vw, 320px);
  height: clamp(180px, 28vw, 320px);
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--color-accent);
  box-shadow: 0 0 0 8px var(--color-accent-subtle);
  display: block;
}

/* Stack portrait below text on very small screens */
@media (max-width: 620px) {
  .hero-layout { flex-direction: column-reverse; align-items: flex-start; }
  .portrait-img { width: 130px; height: 130px; }
}

.hero-eyebrow {
  font-size: 1.1rem;
  color: var(--color-text-subtle);
  margin-bottom: 0.35rem;
  font-weight: 500;
}

#hero-title {
  font-size: clamp(2.5rem, 5vw + 1rem, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.1;
  margin-bottom: 1.25rem;
  color: var(--color-text);
}

.hero-tagline {
  font-size: clamp(1.05rem, 1.5vw + 0.6rem, 1.25rem);
  color: var(--color-text-subtle);
  max-width: 55ch;
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* ============================================================
   Buttons
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast);
}

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

.btn--primary {
  background: var(--color-accent);
  color: var(--color-text-inverted);
}

.btn--primary:hover { background: var(--color-accent-hover); }

.btn--outline {
  background: transparent;
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.btn--outline:hover { background: var(--color-accent-subtle); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-subtle);
  border-color: var(--color-border);
  font-weight: 500;
}

.btn--ghost:hover {
  color: var(--color-text);
  border-color: var(--color-text);
}

.btn--sm {
  font-size: 0.875rem;
  padding: 0.5rem 1.25rem;
}

/* Icon-only button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition-fast);
}

@media (prefers-reduced-motion: reduce) {
  .btn-icon { transition: none; }
}

.btn-icon:hover { background: var(--color-bg-alt); }

/* ============================================================
   About
============================================================ */
.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

@media (min-width: 720px) {
  .about-grid { grid-template-columns: 3fr 2fr; }
}

.about-text p + p { margin-top: 1rem; }

.subsection-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.interest-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.interest-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.975rem;
  color: var(--color-text-subtle);
}

.interest-icon {
  flex-shrink: 0;
  color: var(--color-accent);
}

/* ============================================================
   Projects grid
============================================================ */
.projects-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  box-shadow: var(--shadow-card);
  transition:
    box-shadow var(--transition-med),
    border-color var(--transition-fast),
    transform var(--transition-med);
}

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

.card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--color-accent);
  transform: translateY(-3px);
}

@media (prefers-reduced-motion: reduce) {
  .card:hover { transform: none; }
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  flex-shrink: 0;
}

.card-title { font-size: 1.1rem; font-weight: 700; }

.card-link {
  color: var(--color-text);
  text-decoration: none;
}

.card-link:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.badge--ai {
  background: var(--color-badge-ai-bg);
  color: var(--color-badge-ai-text);
}

.badge--a11y {
  background: var(--color-badge-a11y-bg);
  color: var(--color-badge-a11y-text);
}

.card-desc {
  font-size: 0.925rem;
  color: var(--color-text-subtle);
  line-height: 1.65;
  flex: 1;
}

.card-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.card-tags li {
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  padding: 0.2em 0.6em;
  border-radius: 0.35rem;
}

.card-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: auto;
}

.card-gh-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-subtle);
  text-decoration: none;
  border: 1.5px solid var(--color-border);
  border-radius: 0.4rem;
  padding: 0.25em 0.65em;
  white-space: nowrap;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.card-gh-link:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* ============================================================
   Contact
============================================================ */
.contact-intro {
  font-size: 1.1rem;
  color: var(--color-text-subtle);
  max-width: 52ch;
  margin-bottom: 2rem;
}

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-accent);
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--transition-fast);
}

@media (prefers-reduced-motion: reduce) {
  .contact-link { transition: none; }
}

.contact-link:hover { color: var(--color-accent-hover); }

/* ============================================================
   Footer
============================================================ */
.site-footer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding-block: 2rem;
  text-align: center;
  color: var(--color-text-subtle);
  font-size: 0.9rem;
}

/* ============================================================
   Settings dialog
============================================================ */
.settings-dialog {
  /* Center in viewport (native <dialog> default); override UA styles */
  width: min(92vw, 420px);
  padding: 0;
  border: 1.5px solid var(--color-border);
  border-radius: 1.25rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  box-shadow: var(--shadow-dialog);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.dialog-inner {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.dialog-desc {
  font-size: 0.875rem;
  color: var(--color-text-subtle);
  line-height: 1.55;
  margin-top: -0.75rem;
}

/* Settings fieldset */
.settings-group {
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.settings-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-subtle);
  margin-bottom: 0.15rem;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Option rows (radio + checkbox) */
.option-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
}

.option-row input[type="radio"],
.option-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.hint {
  font-size: 0.82em;
  color: var(--color-text-subtle);
  font-weight: 400;
}

/* ============================================================
   Responsive — small screens
============================================================ */
@media (max-width: 480px) {
  /* Keep nav visible but compact; hide label on settings button */
  .main-nav { display: none; }

  .settings-btn span { display: none; }
  .settings-btn { padding: 0.5rem; border-radius: 50%; }
}
