/* ==========================================================================
   Polyhedra Stylesheet
   ========================================================================== */

/* 1. Global Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px; /* Base readable text size */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #222222;
  background-color: #fcfcfc;
  
  /* Center the page on wide screens and prevent edge-to-edge stretching */
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* 2. Overrides for any remaining legacy <font> tags (Safety Net) */
font, big, small {
  font-family: inherit !important;
  font-size: inherit !important;
}

/* 3. Typography & Headings */
h1, h2, h3, h4 {
  color: #111111;
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  line-height: 1.3;
}

/* Responsive Main Title / Heading */
#title,
#title h1,
#title h2,
h2#title {
  font-size: 2.2rem;
  line-height: 1.2;
  text-align: center;
  margin-top: 0.2em;
  margin-bottom: 0.5em;
}

/* Smaller title on landscape/widescreen displays to optimize vertical space */
@media (min-aspect-ratio: 5/4) {
  #title,
  #title h1,
  #title h2,
  h2#title {
    font-size: 1.6rem;
  }
}

p {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}

/* 4. Links */
a {
  color: #0056b3;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease-in-out;
}

a:visited {
  color: #6f42c1; /* Modern, readable purple */
}

a:hover, a:focus {
  color: #003366;
  text-decoration-thickness: 2px;
}

/* 5. Responsive Images & 3D Previews */

/* General default for banners, diagrams, and icons */
img {
  max-width: 100%;
  height: auto !important;
  display: inline-block;
  vertical-align: middle;
}

/* Banner image at top */
img[src*="poly.gif"] {
  display: block;
  margin-bottom: 12px;
}

/* Polyhedron preview containers */
td a, 
table a {
  display: inline-block !important;
  width: 100% !important;
  max-width: 300px !important;
}

/* Polyhedron images AND 3D WebGL canvases:
   Overrides inline width/height and guarantees zero distortion */
td img, 
td canvas, 
table img, 
table canvas,
a > img[src$=".gif"] {
  width: 100% !important;
  max-width: 300px !important;
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 auto 8px auto !important;
  border-radius: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

td img:hover, 
td canvas:hover, 
table img:hover, 
table canvas:hover,
a > img[src$=".gif"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 6. Tables (General) */
table {
  border-collapse: collapse;
}

/* 7. Lists */
ul {
  padding-left: 24px;
  margin-top: 0.5em;
  margin-bottom: 1.2em;
}

li {
  margin-bottom: 0.4em;
}

/* 8. Notice / Announcement Callout */
.notice,
p:has(a[href*="vrml-revival"]) {
  background-color: #fff3f3;
  border-left: 4px solid #d9383a;
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin: 1.2em 0;
  font-size: 0.95rem;
}

/* 9. "NEW" and "UPDATED" Badges */
span[style*="color: rgb(255, 0, 0)"],
span[style*="color: #ff0000"] {
  display: inline-flex;
  align-items: center;
  background-color: #ffe5e5;
  color: #b30000 !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Hide the tiny arrow.jpg icon inside modern badges */
span[style*="color: rgb(255, 0, 0)"] img[src*="arrow.jpg"],
span[style*="color: #ff0000"] img[src*="arrow.jpg"] {
  display: none;
}

/* 10. Mobile Adjustments */
@media (max-width: 650px) {
  body {
    padding: 16px 12px;
  }
  
  /* Stack 3D preview images on small screens */
  p:has(img[src$=".gif"]) {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  /* Stack ONLY tables that contain polyhedron images or 3D canvases
     (leaves normal text/coordinate data tables unchanged) */
  table:has(img),
  table:has(canvas) {
    display: block !important;
    width: 100% !important;
  }

  table:has(img) tbody,
  table:has(canvas) tbody,
  table:has(img) tr,
  table:has(canvas) tr {
    display: block !important;
    width: 100% !important;
  }

  table:has(img) td,
  table:has(canvas) td {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 20px 0 !important;
    border: none !important;
    border-bottom: 1px solid #e0e0e0 !important;
  }

  /* Hide empty placeholder cells (like row 4 in 2-column tables) */
  table:has(img) td:empty,
  table:has(img) td:has(> br:only-child),
  table:has(canvas) td:empty,
  table:has(canvas) td:has(> br:only-child) {
    display: none !important;
  }
}