/* ==========================================================================
   Dr. Who's Harpoon Pages — styles.css
   Phase 4: replaces inline <font>/bgcolor/table-layout chrome
   Identity preserved: navy palette, Verdana stack, hullbk.gif background
   ========================================================================== */

/* --------------------------------------------------------------------------
   Custom properties — change palette / dimensions in one place
   -------------------------------------------------------------------------- */
:root {
  --color-bg:           #ffffff;
  --color-text:         #000000;
  --color-link:         #000099;
  --color-link-hover:   #0000cc;
  --color-link-visited: #330066;
  --color-accent:       #000099;
  --color-nav-bg:       #1a1a6e;   /* deep navy for nav button background */
  --color-nav-bg-hover: #0000cc;
  --color-nav-text:     #ffffff;
  --color-nav-border:   #3333aa;
  --color-footer-text:  #333333;
  --color-hr:           #aaaaaa;

  --font-stack:         Verdana, Geneva, "DejaVu Sans", sans-serif;
  --font-size-base:     14px;
  --line-height:        1.45;

  --max-width:          960px;
  --nav-width:          155px;
  --content-padding:    1rem 1.25rem;
}

/* --------------------------------------------------------------------------
   Reset / base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-stack);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--color-text);
  /* Iconic hull-plate texture, tiled in both directions like the original */
  background: var(--color-bg) url('/images/hullbk.gif') repeat top left;
}

/* --------------------------------------------------------------------------
   Checkbox hack — nav-toggle input (hidden everywhere)
   -------------------------------------------------------------------------- */
.nav-toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   Layout: CSS Grid
   Desktop (>= 720px): [nav | content]   under masthead   above footer
   Mobile  (< 720px):  single column; hamburger reveals nav
   -------------------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-areas:
    "masthead"
    "nav"
    "main"
    "footer";
  grid-template-columns: 1fr;
  max-width: var(--max-width);
  margin: 0 auto;
  /* No background-color: the body's hullbk.gif texture flows through behind
     the layout, just like the original site. Individual elements (the nav
     buttons, the link tables, etc.) provide their own panels where needed. */
}

@media (min-width: 720px) {
  .layout {
    grid-template-areas:
      "masthead masthead"
      "nav      main"
      "footer   footer";
    grid-template-columns: var(--nav-width) 1fr;
  }
}

/* --------------------------------------------------------------------------
   Masthead
   -------------------------------------------------------------------------- */
.masthead {
  grid-area: masthead;
  display: flex;
  align-items: center;
  justify-content: center;   /* logo centered horizontally */
  position: relative;        /* anchor for absolutely-positioned hamburger on mobile */
  padding: 0;
  /* Replicate the masthead's chrome-plate texture full-width by tiling a
     clean 20x85 strip from a text-free region of logo-drwho.gif (chosen
     by lowest column-variance to avoid embossed-letter artifacts).
     The actual <img> sits centered on top of this tile via the flex layout. */
  background: url('/images/masthead-edge.gif') repeat top left;
}

.masthead a {
  display: block;
  line-height: 0;   /* remove ghost space under inline img */
}

.masthead img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   Hamburger button (visible only on mobile)
   -------------------------------------------------------------------------- */
.hamburger {
  display: none;   /* hidden on desktop */
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-nav-border);
  border-radius: 3px;
  /* Chrome-plate texture matching the masthead and side-nav buttons. */
  background: url('/images/masthead-edge.gif') repeat top left;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background-color: var(--color-text);   /* dark bars on the silver button */
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

@media (max-width: 719px) {
  .hamburger {
    display: flex;
    /* Standard placement: left side of the masthead, ~30px below center
       so it sits closer to the dark subtitle band than the embossed
       logo letters above. */
    position: absolute;
    top: calc(50% + 27px);
    left: 0.5rem;
    transform: translateY(-50%);
  }
}

/* --------------------------------------------------------------------------
   Primary nav
   -------------------------------------------------------------------------- */
.primary-nav {
  grid-area: nav;
  /* No background-color: texture shows behind the nav buttons, which provide
     their own backgrounds. Matches the original site's appearance. */
}

/* Mobile: nav is hidden by default; checkbox hack reveals it */
@media (max-width: 719px) {
  .primary-nav {
    /* collapsed */
    max-height: 0;
    overflow: hidden;
    border-right: none;
    border-bottom: 1px solid var(--color-nav-border);
    transition: max-height 0.25s ease;
  }

  /* when the checkbox is checked, expand the nav */
  .nav-toggle:checked ~ .layout .primary-nav {
    max-height: 800px;   /* generous upper bound — taller buttons on mobile */
  }

  /* Taller buttons on mobile: bigger tap targets (~44px iOS HIG min)
     AND the hover-state submarine reads better at a wider button height. */
  .menu li a {
    padding: 0.6rem 0.6rem;
  }

  /* Animate hamburger lines into an X */
  .nav-toggle:checked ~ .layout .hamburger span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .nav-toggle:checked ~ .layout .hamburger span:nth-child(2) {
    opacity: 0;
  }
  .nav-toggle:checked ~ .layout .hamburger span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

/* Nav menu list */
.menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu li {
  margin: 0;
  padding: 0;
}

.menu li a {
  display: block;
  padding: 0.2rem 0.6rem;       /* tight: ~3px top/bottom for 0-1px gap feel */
  font-size: 0.85rem;
  font-weight: bold;
  font-family: var(--font-stack);
  color: var(--color-text);     /* dark text on the silver chrome */
  text-align: center;            /* matches the original sliced-GIF menu */
  /* Silverish background using the same chrome-plate tile as the masthead.
     The 30x100 tile's top portion (chrome texture) repeats; buttons are
     short enough that the tile's dark band at the bottom never shows. */
  background: url('/images/masthead-edge.gif') repeat top left;
  text-decoration: none;
  border-bottom: 1px solid var(--color-nav-border);
  transition: filter 0.15s;
}

.menu li a:hover,
.menu li a:focus {
  /* Hover/active state: nuclear submarine silhouette, lifted from the
     original menufiles/menu-drwho_r1_c1_f2.gif and rebuilt as a single
     1.4 KB SVG.
     `auto 100%` keeps the sub at its native 6:1 aspect ratio (it
     scales to fit the button's height; width is computed from that).
     On a wide mobile button the sub stays sized correctly, centered,
     with chrome plate filling the sides. */
  background-image:
    url('/images/menu-sub.svg'),
    url('/images/masthead-edge.gif');
  background-repeat: no-repeat, repeat;
  background-size: auto 100%, auto;
  background-position: center, top left;
  text-decoration: none;
  outline: none;
}

/* --------------------------------------------------------------------------
   Main content area
   -------------------------------------------------------------------------- */
main {
  grid-area: main;
  padding: var(--content-padding);
  /* No background-color: hullbk.gif texture shows through behind content,
     matching the original site. */
  min-width: 0;   /* prevent grid blowout from long words */
}

/* --------------------------------------------------------------------------
   Typography: headings + links
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-stack);
  color: var(--color-accent);
}

a {
  color: var(--color-link);
}

a:hover,
a:focus {
  color: var(--color-link-hover);
  text-decoration: underline;
}

a:visited {
  color: var(--color-link-visited);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
footer {
  grid-area: footer;
  /* No background-color: the body's hullbk.gif texture flows through behind
     the footer, matching the rest of the page. */
  border-top: 1px solid var(--color-hr);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--color-footer-text);
}

footer hr {
  display: none;   /* footer already has border-top */
}

footer p {
  margin: 0.3rem 0;
}

/* --------------------------------------------------------------------------
   Bio layout extras
   -------------------------------------------------------------------------- */
.bio-title {
  text-align: center;
  margin-bottom: 0.5rem;
}

.bio-nav {
  text-align: center;
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
}

.bio-nav a {
  margin: 0 0.4rem;
}

/* --------------------------------------------------------------------------
   Pooner ribbon (year selector strip)
   -------------------------------------------------------------------------- */
.pooner-ribbon {
  /* Silver chrome-plate texture, same tile as the masthead and side nav. */
  background: url('/images/masthead-edge.gif') repeat top left;
  border: 1px solid var(--color-nav-border);
  padding: 0.25rem 0.4rem;
  margin: 0.75rem 0;
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;                  /* tight 1px gap between year buttons */
  align-items: center;
}

.pooner-ribbon .ribbon-label {
  font-weight: bold;
  color: var(--color-text);  /* dark on the silver, no blue accent */
  margin-right: 0.4rem;
}

.pooner-ribbon a {
  color: var(--color-text);
  padding: 0.15rem 0.45rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: filter 0.15s;
}

.pooner-ribbon a:hover,
.pooner-ribbon a:focus {
  filter: brightness(1.1);
  text-decoration: underline;
  border-color: var(--color-nav-border);
}

/* --------------------------------------------------------------------------
   FTP directory index pages (generated post-build by scripts/generate-ftp-index.py)
   -------------------------------------------------------------------------- */
table.ftp-index {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-stack);
  font-size: 0.85rem;
  margin: 0.75rem 0;
}
table.ftp-index thead th {
  text-align: left;
  background: url('/images/masthead-edge.gif') repeat top left;
  border-bottom: 1px solid var(--color-nav-border);
  padding: 0.3rem 0.6rem;
}
table.ftp-index td {
  padding: 0.15rem 0.6rem;
  border-bottom: 1px solid #d0d0d0;
}
table.ftp-index td.size,
table.ftp-index th.size {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.ftp-index a {
  color: var(--color-link);
}
table.ftp-index tr:hover td {
  background-color: rgba(0, 0, 153, 0.05);
}

/* --------------------------------------------------------------------------
   Utility: the old <center> tags in body content still work;
   <font> tags still render. We don't touch body content in Phase 4.
   These rules provide sensible defaults for body-content tables that
   use width="100%" — they keep working inside the new narrower main area.
   -------------------------------------------------------------------------- */
main table {
  max-width: 100%;
}

main img {
  max-width: 100%;
  height: auto;
}

/* --------------------------------------------------------------------------
   Print stylesheet — hide nav, simple layout
   -------------------------------------------------------------------------- */
@media print {
  .nav-toggle,
  .hamburger,
  .primary-nav,
  footer {
    display: none !important;
  }

  .layout {
    display: block;
    max-width: 100%;
  }

  .masthead img {
    max-width: 400px;
  }

  body {
    background-image: none;
    background-color: #ffffff;
    color: #000000;
  }

  a {
    color: #000000;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
  }
}
