/*
  Main Stylesheet for webdev.wat.tech
  Watkinson School Web Development Course

  This stylesheet uses design tokens from tokens.css.
  Typography: Amulya (headings), Synonym (body), JetBrains Mono (code)
  Colors: Sand neutrals with orange, cyan, and indigo accents
*/

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

/* Remove list styles on ul, ol elements with a list role */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* Set core root defaults */
html {
  font-size: 100%;
  scroll-behavior: smooth;
}

/* Remove default margin and enable min-height layout */
body {
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  line-height: var(--leading-normal);
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
}

/* Make images easier to work with */
img,
picture {
  max-width: 100%;
  display: block;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
  font: inherit;
}

/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===========================================
   Base Styles
   =========================================== */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-1);
  background-color: var(--background-1);
  display: flex;
  flex-direction: column;
}

/* Subtle texture/gradient on body for depth */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 0%, var(--orange-1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, var(--cyan-1) 0%, transparent 50%);
  opacity: 0.5;
  pointer-events: none;
  z-index: -1;
}

/* ===========================================
   Typography
   =========================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--text-1);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
}

/* First heading in main content shouldn't have top margin */
main > h1:first-child,
.container > h1:first-child {
  margin-top: 0;
}

h1 {
  font-size: var(--text-4xl);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-3xl);
  letter-spacing: -0.01em;
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--sand-4);
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-xl);
}

h5 {
  font-size: var(--text-lg);
}

h6 {
  font-size: var(--text-base);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

p {
  margin-bottom: var(--space-md);
}

/* Lead paragraph style */
.lead {
  font-size: var(--text-lg);
  color: var(--text-2);
  line-height: var(--leading-relaxed);
}

/* Strong and emphasis */
strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

small {
  font-size: var(--text-sm);
}

/* ===========================================
   Links
   =========================================== */
a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

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

a:focus-visible {
  outline: 2px solid var(--brand-color);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===========================================
   Code
   =========================================== */
code,
kbd,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Inline code */
:not(pre) > code {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Code blocks */
pre {
  background-color: var(--sand-15);
  color: var(--sand-3);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-lg);
  line-height: var(--leading-normal);
  box-shadow: var(--shadow-md);
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

/* Keyboard input styling */
kbd {
  background-color: var(--sand-3);
  border: 1px solid var(--sand-5);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  box-shadow: 0 1px 0 var(--sand-6);
}

/* ===========================================
   Layout
   =========================================== */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
  padding-block: var(--space-xl);
  flex: 1;
}

/* Wider container variant */
.container--wide {
  max-width: 75rem;
}

/* Narrow container for reading */
.container--narrow {
  max-width: 45rem;
}

/* ===========================================
   Navigation
   =========================================== */
.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--container-padding);
  background-color: var(--background-2);
  border-bottom: 1px solid var(--sand-4);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.nav-logo {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-1);
  text-decoration: none;
  letter-spacing: -0.02em;
  transition: color var(--transition-fast);
}

.nav-logo:hover {
  color: var(--brand-color);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links li {
  margin: 0;
}

.nav-links a {
  position: relative;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

/* Animated underline for nav links */
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: var(--space-sm);
  right: var(--space-sm);
  height: 2px;
  background-color: var(--brand-color);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s ease;
}

.nav-links a:hover::after,
.nav-links a:focus::after {
  transform: scaleX(1);
}

.nav-links a[aria-current="page"]::after {
  transform: scaleX(1);
}

.nav-links a:hover {
  color: var(--text-1);
  background-color: var(--sand-3);
}

.nav-links a[aria-current="page"] {
  color: var(--brand-color);
  background-color: var(--orange-1);
}

/* ===========================================
   Footer
   =========================================== */
.site-footer {
  margin-top: auto;
  padding: var(--space-xl) var(--container-padding);
  background-color: var(--sand-14);
  color: var(--sand-4);
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: var(--text-sm);
}

.site-footer a {
  color: var(--sand-5);
}

.site-footer a:hover {
  color: var(--sand-2);
}

/* ===========================================
   Lists
   =========================================== */
ul,
ol {
  padding-left: var(--space-xl);
  margin-bottom: var(--space-md);
}

ul {
  list-style-type: disc;
}

ol {
  list-style-type: decimal;
}

li {
  margin-bottom: var(--space-xs);
  line-height: var(--leading-relaxed);
}

li::marker {
  color: var(--text-3);
}

/* Nested lists */
ul ul,
ol ol,
ul ol,
ol ul {
  margin-top: var(--space-xs);
  margin-bottom: 0;
}

/* Description lists */
dl {
  margin-bottom: var(--space-md);
}

dt {
  font-weight: 700;
  color: var(--text-1);
  margin-top: var(--space-md);
}

dd {
  margin-left: var(--space-lg);
  color: var(--text-2);
}

/* ===========================================
   Tables
   =========================================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-xl);
  font-size: var(--text-sm);
}

thead {
  background-color: var(--sand-14);
  color: var(--sand-2);
}

th {
  font-family: var(--font-heading);
  font-weight: 700;
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--sand-12);
}

td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--sand-4);
  vertical-align: top;
}

/* Hover state for table rows */
tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background-color: var(--sand-2);
}

/* Alternating row colors (optional - subtle) */
tbody tr:nth-child(even) {
  background-color: var(--background-2);
}

tbody tr:nth-child(even):hover {
  background-color: var(--sand-3);
}

/* Table wrapper for horizontal scroll on mobile */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--space-xl);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.table-wrapper table {
  margin-bottom: 0;
}

/* ===========================================
   Blockquotes
   =========================================== */
blockquote {
  border-left: 4px solid var(--brand-color);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  background-color: var(--orange-1);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

blockquote p {
  margin-bottom: var(--space-sm);
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote cite {
  font-size: var(--text-sm);
  color: var(--text-3);
  font-style: normal;
}

/* ===========================================
   Horizontal Rule
   =========================================== */
hr {
  border: none;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent,
    var(--sand-5),
    var(--brand-color),
    var(--sand-5),
    transparent
  );
  margin: var(--space-2xl) 0;
}

/* ===========================================
   Alerts / Callouts
   =========================================== */
.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  border-left: 4px solid;
}

.alert--info {
  background-color: var(--cyan-1);
  border-color: var(--cyan-6);
  color: var(--cyan-12);
}

.alert--warning {
  background-color: var(--orange-1);
  border-color: var(--orange-6);
  color: var(--orange-12);
}

.alert--note {
  background-color: var(--alert-bg);
  border-color: var(--alert-border);
  color: var(--alert-text);
}

/* ===========================================
   Buttons (utility)
   =========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background-color: var(--brand-color);
  color: white;
}

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

.btn--secondary {
  background-color: var(--sand-3);
  color: var(--text-1);
}

.btn--secondary:hover {
  background-color: var(--sand-4);
}

/* ===========================================
   Utility Classes
   =========================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-3);
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ===========================================
   Animations
   =========================================== */

/* Keyframe for fade and slide entrance */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Page entrance animation */
main.container {
  animation: fadeSlideIn 0.4s ease-out;
}

/* Staggered heading reveals */
main h1 {
  animation: fadeSlideIn 0.5s ease-out 0.1s both;
}

main h2 {
  animation: fadeSlideIn 0.5s ease-out 0.15s both;
}

main h3 {
  animation: fadeSlideIn 0.5s ease-out 0.2s both;
}

/* ===========================================
   Responsive Adjustments
   =========================================== */

/* Tablet and below */
@media (max-width: 768px) {
  :root {
    --container-padding: var(--space-md);
  }

  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  h3 {
    font-size: var(--text-xl);
  }

  /* Stack navigation on mobile */
  .site-nav {
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
  }

  .nav-links {
    gap: var(--space-sm);
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-links a {
    font-size: var(--text-sm);
    padding: var(--space-xs);
  }

  /* Tables scroll horizontally */
  table {
    display: block;
    overflow-x: auto;
  }

  /* Reduce padding in table cells */
  th,
  td {
    padding: var(--space-xs) var(--space-sm);
  }
}

/* Mobile */
@media (max-width: 480px) {
  :root {
    --container-padding: var(--space-sm);
  }

  h1 {
    font-size: var(--text-2xl);
  }

  h2 {
    font-size: var(--text-xl);
  }

  .container {
    padding-block: var(--space-lg);
  }

  /* Reduce code block padding */
  pre {
    padding: var(--space-md);
    font-size: var(--text-sm);
  }

  /* Smaller list indentation */
  ul,
  ol {
    padding-left: var(--space-lg);
  }
}

/* ===========================================
   Print Styles
   =========================================== */
@media print {
  /* Remove backgrounds and shadows */
  body::before {
    display: none;
  }

  .site-nav,
  .site-footer {
    display: none;
  }

  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  h1, h2, h3, h4, h5, h6 {
    color: black;
    page-break-after: avoid;
  }

  table {
    page-break-inside: avoid;
  }

  thead {
    background: #f0f0f0;
    color: black;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  /* Show URLs for links */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  pre {
    background: #f5f5f5;
    border: 1px solid #ccc;
    box-shadow: none;
  }

  blockquote {
    border-left-color: #999;
    background: transparent;
  }
}
