/*
 * style.css — xyzcat.fyi main stylesheet
 * ───────────────────────────────────────
 * All layout, components, and visual rules live here.
 * Colour values come from tokens.css — never hardcode hex in this file.
 * If you need to change a colour, do it in tokens.css instead.
 *
 * Sections in this file:
 *   1. Reset
 *   2. Base / Body
 *   3. Layout
 *   4. Skip link (accessibility)
 *   5. Header
 *   6. Theme toggle button
 *   7. Nav
 *   8. Main content
 *   9. App cards
 *  10. Footer
 *  11. Responsive
 */


/* ── 1. RESET ─────────────────────────────────────────────────────────────── */
/*
 * Removes browser default spacing and ensures consistent box sizing.
 * box-sizing: border-box means padding and border are included in element
 * width/height — much easier to reason about than the default.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth; /* Smooth jump when using anchor links */
}


/* ── 2. BASE / BODY ───────────────────────────────────────────────────────── */

body {
  background-color: var(--bg);
  color: var(--text-body);
  font-family: var(--font-prose);
  line-height: 1.6;
  min-height: 100vh;    /* Always fills the full viewport height */
  display: flex;
  flex-direction: column; /* Lets the footer stick to the bottom */
}


/* ── 3. LAYOUT ────────────────────────────────────────────────────────────── */
/*
 * .container centres content and limits max width for readability.
 * All page sections sit inside this wrapper.
 */

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem; /* Side padding so content doesn't touch screen edges on mobile */
  display: flex;
  flex-direction: column;
  flex: 1; /* stretches to fill full viewport height so footer reaches the bottom */
}


/* ── 4. SKIP LINK (accessibility) ────────────────────────────────────────── */
/*
 * Hidden off-screen by default. Appears when focused via keyboard (Tab key).
 * Lets keyboard/screen reader users jump straight to main content,
 * skipping the header and nav on every page load.
 */

.skip-link {
  position: absolute;
  top: -999px;    /* Hidden off-screen */
  left: 1rem;
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  z-index: 100;
}

.skip-link:focus {
  top: 1rem;  /* Slides into view when focused */
}


/* ── 5. HEADER ────────────────────────────────────────────────────────────── */

header {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
  position: relative; /* Needed so the toggle button can be positioned top-right */
}

.header-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
}

/*
 * Avatar — currently a placeholder emoji.
 * When the Memoji image is ready, swap the <div class="avatar"> in the HTML
 * for an <img> tag and remove the emoji styles below.
 */
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0; /* Prevents the avatar from squishing on small screens */
}

.header-text h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em; /* Slightly tighter tracking on large headings */
  line-height: 1.2;
}

.header-text .tagline {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 0.35rem;
}

/* Sub-page header (used on /apps, /portfolio, /cv) */
header h1.page-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

header .page-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Back link — used on sub-pages to return to home */
.back-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1.25rem;
  transition: color 0.15s ease;
}

.back-link::before {
  content: "← "; /* Arrow prepended in CSS so it doesn't need to be in the HTML */
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--accent); /* Yellow on hover — consistent with nav */
  outline: none;
}


/* ── 6. THEME TOGGLE ──────────────────────────────────────────────────────── */
/*
 * The toggle button sits in the top-right corner of the header.
 * It's positioned absolutely relative to the <header> element
 * (which has position: relative set in section 5).
 *
 * The ◑ symbol is used — half-filled circle, suggests light/dark split.
 * No words, just the symbol.
 *
 * Behaviour is handled by the <script> at the bottom of each HTML file.
 */

.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 0; /* Aligns to the right edge of the container */

  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;

  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--accent); /* Yellow border on hover */
  color: var(--accent);        /* Yellow symbol on hover */
  outline: none;
}


/* ── 7. NAV ───────────────────────────────────────────────────────────────── */

nav {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap; /* Wraps to next line on small screens */
  gap: 0.5rem;
}

nav a {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-body);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

nav a:hover,
nav a:focus-visible {
  border-color: var(--accent); /* Yellow border on hover */
  color: var(--accent);        /* Yellow text on hover */
  outline: none;
}

/* External links get a ↗ arrow appended automatically */
nav a[target="_blank"]::after {
  content: " ↗";
  font-size: 0.75em;
  opacity: 0.6;
}

/* Current page link — visually active state */
nav a[aria-current="page"] {
  border-color: var(--accent);
  color: var(--accent);
}


/* ── 8. MAIN CONTENT ──────────────────────────────────────────────────────── */

main {
  flex: 1; /* Pushes footer to bottom by taking all available vertical space */
  padding: 2.5rem 0;
}

section {
  margin-bottom: 3rem;
}

/* Small uppercase label above a section — e.g. "things i built" */
.section-label,
section h2 {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}


/* ── 9. APP CARDS ─────────────────────────────────────────────────────────── */
/*
 * Used on both index.html (grid layout) and apps/index.html (list layout).
 * The card itself is an <a> tag — the whole card is clickable.
 */

/* Grid layout — home page */
.app-grid {
  display: grid;
  grid-template-columns: 1fr; /* Single column on mobile */
  gap: 0.75rem;
}

/* List layout — apps page */
.app-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.app-card {
  display: block;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.app-card:hover,
.app-card:focus-visible {
  border-color: var(--accent); /* Yellow border on hover */
  outline: none;
}

/* Card header row — name on left, tag on right */
.app-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-name,
.app-card .app-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  display: block;
}

/* Small label — e.g. "finance", "security" */
.app-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.app-desc,
.app-card .app-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.5;
  display: block;
  font-family: var(--font-mono);
}

/* "open app ↗" label at the bottom of each card */
.app-link-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.75rem;
  transition: color 0.15s ease;
}

.app-card:hover .app-link-label,
.app-card:focus-visible .app-link-label {
  color: var(--accent); /* Yellow on card hover */
}


/* ── 10. FOOTER ───────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
}

footer p {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}


/* ── 11. RESPONSIVE ───────────────────────────────────────────────────────── */
/*
 * @media rules apply styles only when the screen is wide enough.
 * min-width: 480px catches most phones in landscape and small tablets.
 */

@media (min-width: 480px) {
  /* Two-column card grid on wider screens */
  .app-grid {
    grid-template-columns: 1fr 1fr;
  }
}
