/* ==========================================================================
   T.R. Srinath portfolio website — theme stylesheet
   --------------------------------------------------------------------------
   Section map:
     1. Font loading (Google Fonts)
     2. Theme tokens (:root palette + typography custom properties)
     3. Base elements
     4. Typography: headings + body
     5. Links
     6. Navigation bar (white-on-maroon)
     7. Buttons
     8. Footer
   Palette + typography are defined here (task 8.1).
   The responsive layout model (breakpoints, :focus-visible) is appended
   below this block by task 8.2 — keep base/theme rules above, layout below.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Font loading
   --------------------------------------------------------------------------
   Two families are loaded from Google Fonts: Marcellus (headings) and
   Mukta (body). The @import below is the documented loading mechanism and
   works without touching every HTML <head>.

   Equivalent <link> approach (place in each page's <head> before this
   stylesheet if you prefer link-based loading over @import):
     <link rel="preconnect" href="https://fonts.googleapis.com">
     <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
     <link href="https://fonts.googleapis.com/css2?family=Marcellus&family=Mukta:wght@400;500;600;700&display=swap" rel="stylesheet">

   If the remote fonts fail to load, the fallback stacks defined in the
   --font-* tokens guarantee a defined font is always applied (Req 8.5).
   -------------------------------------------------------------------------- */
@import url("https://fonts.googleapis.com/css2?family=Marcellus&family=Mukta:wght@400;500;600;700&display=swap");

/* --------------------------------------------------------------------------
   2. Theme tokens — single source of truth for palette + typography (Req 8.1, 8.2)
   -------------------------------------------------------------------------- */
:root {
  /* Palette — exactly 6 colors, traditional Carnatic / temple aesthetic */
  --color-maroon: #6B1E1E;   /* primary: nav bar, headings, footer        */
  --color-saffron: #E2711D;  /* accent: active state, buttons, link hover */
  --color-gold: #C9A227;     /* secondary accent: borders, dividers, rules*/
  --color-cream: #FBF3E3;    /* page background (sandalwood cream)        */
  --color-surface: #FFFDF8;  /* cards, modal, track-list surfaces         */
  --color-ink: #2B1A14;      /* body text (deep brown-black)              */

  /* On-color text token used for white-on-maroon UI (nav, buttons) */
  --color-on-maroon: #FFFFFF;

  /* Typography — exactly 2 families, each with a local fallback stack so
     no element ever renders with an undefined font (Req 8.5). */
  --font-heading: "Marcellus", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Mukta", "Segoe UI", system-ui, Arial, sans-serif;

  /* Shared rhythm tokens */
  --line-height-body: 1.6;
  --rule-gold: 3px solid var(--color-gold);
}

/* --------------------------------------------------------------------------
   3. Base elements
   --------------------------------------------------------------------------
   CSS custom-property fallbacks (the 2nd argument to var()) are supplied on
   the page-level background and text so that even if a token were undefined
   the page still renders with a defined color from the same palette (Req 8.5).
   -------------------------------------------------------------------------- */
body {
  margin: 0;
  background-color: var(--color-cream, #FBF3E3);
  color: var(--color-ink, #2B1A14);
  font-family: var(--font-body);
  line-height: var(--line-height-body);
  font-weight: 400;
}

/* --------------------------------------------------------------------------
   4. Typography — headings + body (Req 8.4, 10.6)
   --------------------------------------------------------------------------
   Headings: maroon text in the heading font. Contrast of maroon (#6B1E1E)
   on cream (#FBF3E3) is well above the 3:1 large-text threshold (Req 10.6).
   Body: ink on cream/surface exceeds the 4.5:1 body-text threshold.
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-maroon, #6B1E1E);
  font-weight: 400;
  line-height: 1.2;
  margin: 0 0 0.5em;
}

/* Page titles (h1, h2) carry a thin gold underline rule as the section motif. */
h1,
h2 {
  padding-bottom: 0.3em;
  border-bottom: var(--rule-gold);
}

/* Section labels (e.g. Lineage_Section, Recognition_Section): heading font,
   uppercase, letter-spaced, with a small gold divider underneath. */
.section-label {
  font-family: var(--font-heading);
  color: var(--color-maroon, #6B1E1E);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 2px solid var(--color-gold);
  padding-bottom: 0.25em;
}

p {
  margin: 0 0 1em;
  line-height: var(--line-height-body);
}

/* --------------------------------------------------------------------------
   5. Links
   --------------------------------------------------------------------------
   Body links use maroon (≥4.5:1 on cream/surface); hover/focus shifts to
   saffron for an accent without dropping below contrast for normal-size body
   text only where the underline + color change keep them identifiable.
   -------------------------------------------------------------------------- */
a {
  color: var(--color-maroon, #6B1E1E);
  text-decoration: underline;
  text-decoration-color: var(--color-gold);
}

a:hover,
a:focus {
  color: var(--color-saffron, #E2711D);
}

/* --------------------------------------------------------------------------
   6. Navigation bar — white on maroon (Req 8.3, 10.6)
   --------------------------------------------------------------------------
   White (#FFFFFF) on maroon (#6B1E1E) exceeds the 4.5:1 body threshold.
   Placement, color, and font family are identical on every page because all
   pages link this single stylesheet.
   -------------------------------------------------------------------------- */
.site-header {
  background-color: var(--color-maroon, #6B1E1E);
  color: var(--color-on-maroon, #FFFFFF);
  font-family: var(--font-body);
}

.site-nav a {
  color: var(--color-on-maroon, #FFFFFF);
  text-decoration: none;
  font-family: var(--font-body);
}

.site-nav a:hover,
.site-nav a:focus {
  color: var(--color-cream, #FBF3E3);
}

/* Persistent active-state indicator: saffron accent rule (Req 1.5). */
.site-nav a.is-active,
.site-nav a[aria-current="page"] {
  color: var(--color-on-maroon, #FFFFFF);
  border-bottom: 3px solid var(--color-saffron);
}

/* --------------------------------------------------------------------------
   7. Buttons — white on maroon, saffron on hover
   -------------------------------------------------------------------------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--color-on-maroon, #FFFFFF);
  background-color: var(--color-maroon, #6B1E1E);
  border: 2px solid var(--color-gold);
  border-radius: 4px;
  padding: 0.6em 1.2em;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:hover,
.btn:focus {
  background-color: var(--color-saffron, #E2711D);
  color: var(--color-on-maroon, #FFFFFF);
}

/* --------------------------------------------------------------------------
   8. Footer — white on maroon, gold top rule
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--color-maroon, #6B1E1E);
  color: var(--color-on-maroon, #FFFFFF);
  font-family: var(--font-body);
  border-top: var(--rule-gold);
}

.site-footer a {
  color: var(--color-cream, #FBF3E3);
}

/* ==========================================================================
   END OF THEME (task 8.1).
   Task 8.2 appends the responsive layout model and :focus-visible styles
   below this line.
   ========================================================================== */

/* ==========================================================================
   RESPONSIVE LAYOUT MODEL (task 8.2)
   --------------------------------------------------------------------------
   Mobile-first stylesheet implementing Requirement 9 (Responsive Layout) and
   Requirement 10.5 (visible keyboard focus indicator).

   Section map:
     9.  Box model + overflow guards (no horizontal scrollbar 320–2560px)
     10. Fluid media (images/video stay within their containers)
     11. Centered max-width content container
     12. Mobile-first base layout (single column, 320–767px)
     13. :focus-visible focus indicator for all interactive controls (10.5)
     14. Breakpoint: tablet (768–1023px)
     15. Breakpoint: desktop multi-column (1024–2560px)
     16. Very wide viewports (container stays centered)

   Approach: layout is mobile-first. Base rules below the breakpoints target
   the 320–767px single-column phone layout (Req 9.3). Media queries layer on
   the tablet (Req 9.2) and desktop multi-column (Req 9.1) layouts. Because
   the breakpoints are pure CSS media queries, resizing across a breakpoint
   re-applies the layout instantly with no page reload (Req 9.5).
   ========================================================================== */

/* --------------------------------------------------------------------------
   9. Box model + overflow guards
   --------------------------------------------------------------------------
   border-box universally so paddings/borders never add to declared widths
   (a common source of horizontal overflow). overflow-x:hidden on the root
   and body guarantees no horizontal scrollbar at any width 320–2560px
   (Req 9.4, 9.6). width:100% (not 100vw, which ignores the scrollbar gutter)
   avoids introducing its own overflow.
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   10. Fluid media — images and video never exceed their container (Req 9.4)
   --------------------------------------------------------------------------
   Images scale down to the width of their box and keep their aspect ratio.
   The same treatment is applied to native <video> and <iframe> embeds so the
   Video page and any media block also stay within bounds.
   -------------------------------------------------------------------------- */
img,
video,
iframe {
  max-width: 100%;
  height: auto;
}

/* Media that fails to load still occupies its allocated box so the page
   layout is preserved and a placeholder can fill the space (Req 9.7). */
img {
  display: block;
}

/* Hide the broken image once its placeholder is shown (Req 3.11, 9.7). */
img.is-error {
  display: none;
}

/* In-place placeholder for a failed image (Req 9.7, 3.11). Sized inline to the
   image's allocated box by js/media-errors.js (width / aspect-ratio), so the
   surrounding layout never collapses into a blank gap. For the About portrait
   the text is the image's alt, keeping it visible where the image would be. */
.media-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1rem;
  text-align: center;
  color: var(--color-ink, #2b1a14);
  background-color: var(--color-surface, #fffdf8);
  border: 1px dashed var(--color-gold, #c9a227);
  border-radius: 4px;
  font-style: italic;
}

/* Inline media load-error messages for the audio (Req 4.6) and video (Req 5.2)
   players. Hidden via the `hidden` attribute until a watchdog reveals them. */
.audio-error,
.media-error {
  margin-block: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--color-maroon, #6b1e1e);
  background-color: var(--color-surface, #fffdf8);
  border-left: 4px solid var(--color-maroon, #6b1e1e);
  border-radius: 4px;
}

[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   11. Centered max-width content container
   --------------------------------------------------------------------------
   .container centers page content and caps its line length on very wide
   viewports so content does not stretch edge-to-edge on large monitors.
   It is fluid below the cap and carries comfortable side padding on phones.
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 1rem;
}

/* --------------------------------------------------------------------------
   12. Mobile-first base layout — single column (320–767px, Req 9.3)
   --------------------------------------------------------------------------
   Everything stacks in one column by default. The nav links list collapses
   (the JS toggle is wired in task 9.x); here we define the *layout* side:
   below 768px #primary-nav stacks vertically and is hidden until expanded,
   and the hamburger toggle is shown.
   -------------------------------------------------------------------------- */

/* Generic single-column content stack used by page main regions. */
.content-grid,
.about-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Gallery grid: 1–2 columns on phones (auto-fill keeps thumbnails fluid and
   prevents overflow at 320px). */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

/* Navigation layout (mobile): links stack; collapsed by default. The
   hamburger button controls visibility via aria-expanded (wired in task 9).
   These rules define the collapsed/expanded *layout*; the toggle behavior
   lives in main.js. */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#primary-nav {
  display: none;
  flex-direction: column;
  width: 100%;
}

/* When the toggle marks the menu expanded, reveal the stacked links. */
#primary-nav.is-open,
.nav-toggle[aria-expanded="true"] + #primary-nav {
  display: flex;
}

/* --------------------------------------------------------------------------
   13. :focus-visible focus indicator for all interactive controls (Req 10.5)
   --------------------------------------------------------------------------
   A clearly visible outline drawn in the theme saffron, with a contrasting
   gold-toned offset shadow so the indicator is visible on both light (cream)
   and dark (maroon) surfaces. Applied to every natively focusable control.
   :focus-visible is used so the ring shows for keyboard navigation without
   appearing on mouse clicks; a :focus fallback covers older browsers.
   -------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
audio:focus-visible,
video:focus-visible,
[tabindex]:focus-visible,
.nav-toggle:focus-visible,
.site-nav a:focus-visible,
.btn:focus-visible {
  outline: 3px solid var(--color-saffron, #E2711D);
  outline-offset: 2px;
  border-radius: 2px;
  /* Halo improves visibility of the saffron ring against the maroon nav. */
  box-shadow: 0 0 0 5px rgba(201, 162, 39, 0.6); /* --color-gold @ 60% */
}

/* Fallback for browsers without :focus-visible support — keep a visible ring
   on keyboard/programmatic focus rather than removing the default outline. */
a:focus,
button:focus,
.nav-toggle:focus,
.btn:focus {
  outline: 3px solid var(--color-saffron, #E2711D);
  outline-offset: 2px;
}

/* Where :focus-visible IS supported, suppress the plain :focus ring on
   pointer interaction to avoid a double/persistent outline on click. */
@supports selector(:focus-visible) {
  a:focus:not(:focus-visible),
  button:focus:not(:focus-visible),
  .nav-toggle:focus:not(:focus-visible),
  .btn:focus:not(:focus-visible) {
    outline: none;
  }
}

/* --------------------------------------------------------------------------
   14. Breakpoint: tablet (768–1023px, Req 9.2)
   --------------------------------------------------------------------------
   At 768px the nav expands to a horizontal bar and the hamburger is hidden;
   content moves to a relaxed two-column model where appropriate.
   -------------------------------------------------------------------------- */
@media (min-width: 768px) {
  /* Nav: horizontal, always visible; hide the hamburger toggle. */
  .nav-toggle {
    display: none;
  }

  #primary-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    width: auto;
  }

  /* About page: portrait + text side by side at tablet width. */
  .about-layout {
    grid-template-columns: minmax(180px, 1fr) 2fr;
    align-items: start;
  }

  /* Two-column content where a page opts in. */
  .content-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Gallery: 2–3 fluid columns. */
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
}

/* --------------------------------------------------------------------------
   15. Breakpoint: desktop multi-column (1024–2560px, Req 9.1)
   --------------------------------------------------------------------------
   At 1024px and above the layout presents two or more content columns.
   -------------------------------------------------------------------------- */
@media (min-width: 1024px) {
  /* Two-or-more content columns satisfies the desktop layout requirement. */
  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
  }

  /* About: portrait column + wider text column. */
  .about-layout {
    grid-template-columns: minmax(240px, 1fr) 2.2fr;
    gap: 2rem;
  }

  /* Gallery: 3–4 fluid columns. */
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.25rem;
  }
}

/* --------------------------------------------------------------------------
   16. Very wide viewports (up to 2560px)
   --------------------------------------------------------------------------
   The .container max-width (section 11) already centers content and prevents
   edge-to-edge stretch. On very wide screens, allow the gallery a few more
   columns while content text stays capped and centered.
   -------------------------------------------------------------------------- */
@media (min-width: 1600px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* ==========================================================================
   END OF RESPONSIVE LAYOUT MODEL (task 8.2)
   ========================================================================== */

/* ==========================================================================
   Gallery Lightbox modal (task 13.2, Requirements 6.4, 6.5, 10.4)
   --------------------------------------------------------------------------
   A fixed full-viewport overlay with a dimmed backdrop and a centered enlarged
   image. Hidden via the `hidden` attribute until a thumbnail is activated. The
   close button is a standard focusable control (it inherits the shared
   :focus-visible ring above). Layout uses fl/center so the image stays within
   the viewport with no horizontal overflow (Requirement 9.4/9.6).
   ========================================================================== */
.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 26, 20, 0.85); /* deep --color-ink wash */
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 1100px);
  max-height: 90vh;
  background: var(--color-surface, #FFFDF8);
  border: 2px solid var(--color-gold, #C9A227);
  border-radius: 4px;
  padding: 0.75rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 1.5rem);
  height: auto;
  margin: 0 auto;
}

.lightbox-close {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: #ffffff;
  background: var(--color-maroon, #6B1E1E);
  border: 2px solid var(--color-gold, #C9A227);
  border-radius: 50%;
  cursor: pointer;
}

.lightbox-close:hover {
  background: var(--color-saffron, #E2711D);
}
