/* Self-hosted fonts (Google Fonts: Saira Condensed, Oswald) */
@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../assets/fonts/saira-condensed-900-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
  src: url('../assets/fonts/oswald-latin.woff2') format('woff2');
}

/* McMaster-Carr design tokens extracted from mcmaster.com */
:root {
  --color-text: #333;
  --color-text-muted: #666;
  --color-green: #363;
  --color-green-logo: #346734;
  --color-link: #069;
  --color-border: #999;
  --color-yellow-selected: #ffe600;
  --color-yellow-hover: #ffffb5;
  --color-white: #fff;
  --sidebar-width: 210px;
  --tile-width: 80px;
  --tile-height: 118px;
}

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

html {
  color: var(--color-text);
  background: var(--color-white);
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-white);
  color: var(--color-text);
  font: normal 12px arial, helvetica, sans-serif;
  line-height: 1.3;
  height: 100%;
  overflow: hidden;
}

a { color: var(--color-link); }
img { outline: none; max-width: 100%; }

.TopRul { border-top: solid 1px var(--color-border); }
.VerticalSeprt { color: var(--color-border); }
.SecondaryLnk { color: var(--color-link); font-size: 11px; }
.BottomNavLnk {
  color: #000 !important;
  text-decoration: none;
  font-size: 11px;
  display: inline-block;
  padding: 3px 7px;
}

.BottomNavLnk:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Shell layout */
#shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Masthead */
#masthead {
  flex-shrink: 0;
  background: var(--color-white);
  border-bottom: 2px solid var(--color-yellow-selected);
  z-index: 100;
}

.masthead-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 10px 2px 15px;
  min-height: 22px;
  background: var(--color-white);
  border-top: 2px solid var(--color-green);
}

.masthead-top-right {
  display: flex;
  gap: 0;
  font-family: arial, sans-serif;
  font-size: 12px;
}

.masthead-link {
  color: var(--color-text);
  text-decoration: none;
  padding: 0 6px;
  font-weight: 500;
}

.masthead-link:not(:first-child)::before {
  content: "|";
  color: var(--color-text);
  margin-right: 6px;
}

.masthead-link:hover { text-decoration: underline; }

.browse-catalog-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font: 600 12px/1 'Oswald', arial, sans-serif;
  text-transform: uppercase;
  color: var(--color-green);
  cursor: pointer;
  padding: 2px 0;
  letter-spacing: 0.3px;
}

.browse-icon {
  display: inline-block;
  width: 13px;
  height: 11px;
  background: var(--color-green);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 14'%3E%3Crect y='0' width='16' height='2' fill='black'/%3E%3Crect y='6' width='16' height='2' fill='black'/%3E%3Crect y='12' width='16' height='2' fill='black'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 14'%3E%3Crect y='0' width='16' height='2' fill='black'/%3E%3Crect y='6' width='16' height='2' fill='black'/%3E%3Crect y='12' width='16' height='2' fill='black'/%3E%3C/svg%3E") center/contain no-repeat;
}

.masthead-main {
  display: flex;
  align-items: center;
  padding: 6px 10px 8px 15px;
  gap: 12px;
}

.logo-container { flex-shrink: 0; }

.logo-wordmark {
  display: inline-block;
  font-family: 'Saira Condensed', 'Arial Narrow', sans-serif;
  font-weight: 900;
  font-size: 32px;
  line-height: 1;
  color: var(--color-green-logo);
  text-decoration: none;
  letter-spacing: -1px;
  white-space: nowrap;
}

.logo-reg {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 3px;
  vertical-align: baseline;
  overflow: visible;
}

.search-container {
  flex: 1;
  max-width: 620px;
}

#search-form {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  height: 30px;
}

.searchbar {
  flex: 1;
  border: none;
  outline: none;
  padding: 4px 8px;
  font: normal 12px arial, helvetica, sans-serif;
  min-width: 0;
  color: var(--color-text);
}

.searchbar::placeholder {
  color: #999;
  opacity: 1;
}

.clear-button {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.clear-button.inactive { display: none; }

.clear-button:not(.inactive)::after {
  content: "×";
  font-size: 16px;
  color: var(--color-border);
}

.search-separator {
  color: var(--color-border);
  padding: 0 2px;
}

.search-separator.inactive { display: none; }

.searchbar-button {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--color-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.2'/%3E%3Cline x1='15.2' y1='15.2' x2='20' y2='20'/%3E%3C/svg%3E") center/17px no-repeat;
  cursor: pointer;
  flex-shrink: 0;
}

.camera-button {
  width: 30px;
  height: 28px;
  border: none;
  border-left: 1px solid #ddd;
  background: var(--color-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8h2.2l1.3-1.8h7L17 8h2a1.2 1.2 0 011.2 1.2v8.6A1.2 1.2 0 0119 19H5a1.2 1.2 0 01-1.2-1.2V9.2A1.2 1.2 0 015 8z'/%3E%3Ccircle cx='12' cy='13.2' r='3'/%3E%3C/svg%3E") center/17px no-repeat;
  cursor: pointer;
  flex-shrink: 0;
}

.masthead-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0;
}

.masthead-nav a {
  color: var(--color-green);
  text-decoration: none;
  font-family: 'Oswald', arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 4px 10px;
}

.masthead-nav a:hover { text-decoration: underline; }

.masthead-login { display: inline-flex; align-items: center; gap: 3px; }

.login-caret {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--color-text);
}

/* Layout */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid #ccc;
  background: var(--color-white);
}

#homepage-nav {
  height: 100%;
  padding: 3px 0 0;
}

.nav-title {
  font-family: arial, sans-serif;
  font-size: 13px;
  font-weight: bold;
  color: var(--color-text);
  text-align: left;
  margin: 0;
  padding: 5px 12px 6px 15px;
  line-height: 1.2;
  border-bottom: 1px solid var(--color-green);
}

#category-links {
  display: block;
  padding-top: 6px;
}

.nav-cat-link {
  overflow: hidden;
  color: var(--color-text);
  display: block;
  font-size: 13.5px;
  font-family: arial, sans-serif;
  text-decoration: none;
  margin-left: 4px;
  border-left: 4px solid transparent;
  padding: 5px 10px 5px 11px;
  cursor: pointer;
  line-height: 1.4;
}

.nav-cat-link:first-child { margin-top: 0; }

.nav-cat-link.selected {
  background-color: var(--color-yellow-selected);
  color: #000;
  font-weight: bold;
  text-decoration: none;
}

.nav-cat-link:hover {
  background-color: var(--color-yellow-hover);
  text-decoration: underline;
}

/* Main content */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 20px 20px;
  background: var(--color-white);
}

/* "All Categories" bar — aligns with sidebar Choose a Category rule */
#homepage-title {
  padding-top: 3px;
  margin-bottom: 0;
}

.all-categories-bar {
  font-size: 13px;
  font-weight: normal;
  color: var(--color-link);
  font-family: arial, helvetica, sans-serif;
  padding: 5px 0 6px 0;
  border-bottom: 1px solid var(--color-green);
  margin-bottom: 4px;
  line-height: 1.2;
}

#homepage .catg {
  clear: left;
  position: relative;
  background: white;
  padding-bottom: 4px;
  overflow: hidden;
}

#homepage .catg h1.noBorder {
  border-top: none;
  min-height: 4px;
}

#homepage .catg h1 {
  border-top: none;
  display: block;
  margin: 0 0 6px;
  cursor: default;
  color: var(--color-green);
  font-family: arial, sans-serif;
  font-size: 24px;
  font-weight: bold;
  letter-spacing: -0.5px;
  padding-top: 2px;
  line-height: 1.15;
}

#homepage .catg + .catg h1 {
  border-top: 1px solid var(--color-green);
  margin-top: 10px;
  padding-top: 8px;
}

#homepage .subcat {
  display: inline-block;
  float: left;
  padding-bottom: 10px;
}

#homepage .subcat h2 {
  color: var(--color-text);
  font-family: arial, sans-serif;
  font-size: 15px;
  font-weight: bold;
  cursor: default;
  padding: 0 0 6px 2px;
  white-space: nowrap;
  margin: 0;
}

#homepage .subcat ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: inline;
  float: left;
}

#homepage .subcat li {
  display: inline-block;
  float: left;
  width: var(--tile-width);
  height: var(--tile-height);
  overflow: hidden;
  vertical-align: top;
}

#homepage .subcat a {
  display: block;
  position: relative;
  padding: 0 2px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-family: arial, sans-serif;
  line-height: 1.15;
  text-decoration: none;
  text-align: center;
  overflow-wrap: break-word;
  word-break: break-word;
}

#homepage .subcat a:hover {
  text-decoration: underline;
  color: var(--color-link);
}

#homepage .subcat img {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 5px;
  object-fit: contain;
  filter: grayscale(100%);
  border: 1px solid #e8e8e8;
  background: #fff;
}

#homepage .subcat a:hover img {
  filter: grayscale(80%);
}

/* Footer — two-tier like McMaster (links row, then legal) */
#bottom-nav {
  flex-shrink: 0;
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
}

.bottom-nav-inner {
  display: block;
  padding: 5px 12px 6px 8px;
}

.bottom-nav-inner.TopRul { border-top: none; }

.bottom-nav-links {
  display: block;
  line-height: 1.4;
}

.bottom-nav-terms {
  display: block;
  margin-top: 2px;
  line-height: 1.35;
}

.bottom-nav-terms .TermsTxt {
  color: #666;
  font-size: 11px;
}

.bottom-nav-terms .BottomNavLnk {
  color: #069 !important;
  padding: 0;
}

/* Browse overlay (mobile) */
.browse-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.browse-menu {
  background: var(--color-white);
  width: 100%;
  max-width: 360px;
  height: 100%;
  overflow-y: auto;
}

.browse-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.browse-logo { font-size: 26px; }

.close-button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
}

.close-button::before,
.close-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 2px;
  background: var(--color-text);
}

.close-button::before { transform: translate(-50%, -50%) rotate(45deg); }
.close-button::after { transform: translate(-50%, -50%) rotate(-45deg); }

.browse-category-list {
  list-style: none;
  margin: 0;
  padding: 8px;
}

.browse-category-list li { margin-bottom: 4px; }

.browse-cat-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  text-decoration: none;
  color: var(--color-text);
  border: 1px solid #eee;
}

.browse-cat-tile img {
  width: 48px;
  height: 48px;
  filter: grayscale(100%);
}

.browse-cat-tile span {
  font-size: 14px;
  font-weight: bold;
}

/* Mobile / touch layout (McMaster-style) */
@media screen and (max-width: 768px) {
  body { overflow: auto; }
  #shell { height: auto; min-height: 100vh; overflow: visible; }

  .browse-catalog-btn { display: flex; }

  #sidebar { display: none; }

  #layout { flex-direction: column; overflow: visible; }

  #main-content {
    overflow: visible;
    padding: 0 10px 20px;
  }

  #homepage .catg h1 {
    font-size: 17px;
    scroll-margin-top: 80px;
  }

  #homepage .subcat li {
    width: 80px;
    height: 120px;
  }

  #homepage .subcat img {
    width: 64px;
    height: 64px;
  }

  #homepage .subcat a {
    font-size: 11px;
  }

  .masthead-main {
    flex-wrap: wrap;
    padding: 6px 8px;
  }

  .logo-wordmark { font-size: 26px; }

  .search-container {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }

  .masthead-nav { margin-left: auto; }

  .bottom-nav-inner {
    padding: 6px 10px 8px;
  }

  .BottomNavLnk { padding: 3px 4px; }
}

@media screen and (max-width: 480px) {
  /* Keep fixed tile width — percentage widths squash single-item rows
     (e.g. Papers is alone under Publications). */
  #homepage .subcat li {
    width: 80px;
    height: 120px;
  }

  #homepage .subcat img {
    width: 64px;
    height: 64px;
    max-width: none;
  }
}

/* Papers listing page — McMaster products/screws style */
body.papers-page {
  overflow: auto;
}

body.papers-page #shell {
  height: auto;
  min-height: 100vh;
  overflow: visible;
}

.papers-layout {
  flex: 1;
  display: block;
  overflow: visible;
  background: var(--color-white);
}

.papers-main {
  float: none;
  width: auto;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 40px;
  overflow: visible;
}

.product-section {
  margin-bottom: 28px;
}

.product-section-head {
  margin: 8px 0 12px;
}

.product-count {
  color: #666;
  font-size: 12px;
  font-family: arial, sans-serif;
  margin-bottom: 2px;
}

.product-section-title {
  margin: 0;
  padding: 0;
  color: var(--color-green);
  font: bold 22px/1.15 arial, helvetica, sans-serif;
  border: none;
}

.product-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.product-card {
  border: 1px solid #ccc;
  background: #fff;
  min-height: 110px;
}

.product-card a {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px 12px 10px;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.product-card a:hover .product-title {
  text-decoration: underline;
  color: var(--color-link);
}

.product-card a.no-pdf {
  cursor: default;
}

.product-card a.no-pdf:hover .product-title {
  text-decoration: none;
  color: #000;
}

.product-img {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e8e8e8;
  filter: grayscale(100%);
}

.product-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-top: 2px;
}

.product-title {
  display: block;
  color: #000;
  font: bold 13px/1.25 arial, helvetica, sans-serif;
}

.product-desc {
  display: block;
  color: #333;
  font: normal 12px/1.35 arial, helvetica, sans-serif;
}

.product-grid-single {
  grid-template-columns: 1fr;
  max-width: 560px;
}

.product-card-wide .product-img-lg {
  flex: 0 0 140px;
  width: 140px;
  height: 140px;
}

@media screen and (max-width: 800px) {
  .product-grid {
    grid-template-columns: 1fr;
  }

  .papers-main {
    padding: 10px 10px 32px;
  }

  .product-card-wide .product-img-lg {
    flex: 0 0 100px;
    width: 100px;
    height: 100px;
  }
}

/* Stack Media below Publications on homepage */
#homepage .subcat.subcat-stack {
  clear: left;
  float: none;
  display: block;
  width: 100%;
}

/* Communications: stack subcats tightly (no float gap) */
#communications .subcat {
  float: none;
  display: block;
  width: 100%;
  padding-bottom: 0;
  overflow: hidden;
}

#communications .subcat li {
  float: none;
  height: 92px;
}

#communications .subcat ul {
  float: none;
  display: flex;
  flex-wrap: wrap;
}

#communications .subcat.subcat-stack {
  clear: none;
  margin-top: 0;
}

#communications .subcat.subcat-stack h2 {
  padding-top: 0;
  margin-top: 0;
}

/* Research: stack Techniques below Atmospheric Chemistry */
#research .subcat {
  float: none;
  display: block;
  width: 100%;
  padding-bottom: 0;
  overflow: visible;
}

#research .subcat li {
  float: none;
  height: auto;
  min-height: var(--tile-height);
  overflow: visible;
}

#research .subcat ul {
  float: none;
  display: flex;
  flex-wrap: wrap;
}

#research .subcat.subcat-stack {
  clear: none;
  margin-top: 0;
}

#research .subcat.subcat-stack h2 {
  padding-top: 0;
  margin-top: 0;
}

/* Category landing page intro (McMaster eyebolts-style blurb) */
.category-intro {
  margin: 6px 0 14px;
  max-width: 720px;
  color: #333;
  font: normal 13px/1.45 arial, helvetica, sans-serif;
}

/* Category tile grid on research landing pages */
.category-tile-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
}

.category-tile-grid li {
  width: 80px;
  text-align: center;
  vertical-align: top;
}

.category-tile-grid a {
  display: block;
  padding: 0 2px;
  color: var(--color-text-muted);
  font-size: 11px;
  font-family: arial, sans-serif;
  line-height: 1.15;
  text-decoration: none;
  text-align: center;
}

.category-tile-grid a:hover {
  text-decoration: underline;
  color: var(--color-link);
}

.category-tile-grid img {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 5px;
  object-fit: contain;
  filter: grayscale(100%);
  border: 1px solid #e8e8e8;
  background: #fff;
}

.category-tile-grid a:hover img {
  filter: grayscale(80%);
}

/* McMaster duct-tape-style catalog data tables */
.catalog-table-wrap {
  overflow-x: auto;
  margin-top: 6px;
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font: normal 12px/1.35 arial, helvetica, sans-serif;
  color: #000;
}

.catalog-table thead {
  border-top: 1px solid #ccc;
}

.catalog-table th {
  padding: 4px 16px 4px 0;
  font-weight: bold;
  text-align: left;
  vertical-align: bottom;
  background: #fff;
  border: none;
  border-bottom: 1px solid #000;
  color: #000;
  white-space: nowrap;
}

.catalog-table th + th {
  padding-left: 32px;
}

.catalog-table td {
  padding: 5px 16px 5px 0;
  border: none;
  border-bottom: 1px solid #ddd;
  vertical-align: top;
  background: #fff;
  color: #000;
}

.catalog-table td + td {
  padding-left: 32px;
}

.catalog-table tbody tr:last-child td {
  border-bottom: 1px solid #ccc;
}

.catalog-table .col-narrow {
  width: 64px;
}

.catalog-table .col-medium {
  width: 240px;
}

.catalog-table .col-location {
  width: 44%;
}

.catalog-table .col-title {
  width: 56%;
}

.catalog-table a {
  color: var(--color-link);
  text-decoration: none;
}

.catalog-table a:hover {
  text-decoration: underline;
}

/* Email Us modal (McMaster-style) */
.email-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.email-overlay.hidden {
  display: none;
}

.email-panel {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid #999;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  padding: 18px 20px 16px;
  font-family: arial, helvetica, sans-serif;
}

.email-panel h2 {
  margin: 0 0 4px;
  color: var(--color-green);
  font: bold 18px/1.2 arial, helvetica, sans-serif;
}

.email-panel-sub {
  margin: 0 0 14px;
  color: #666;
  font-size: 12px;
  line-height: 1.35;
}

.email-form label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  color: #333;
}

.email-form label span {
  display: block;
  margin-bottom: 3px;
  font-weight: bold;
}

.email-form input,
.email-form textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #999;
  padding: 6px 8px;
  font: normal 13px/1.3 arial, sans-serif;
}

.email-form textarea {
  min-height: 100px;
  resize: vertical;
}

.email-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.email-form-actions button {
  border: 1px solid #666;
  padding: 6px 14px;
  font: bold 12px arial, sans-serif;
  cursor: pointer;
}

.email-form-actions button[type="submit"] {
  background: var(--color-green);
  border-color: var(--color-green);
  color: #fff;
}

.email-form-actions button[type="button"] {
  background: #eee;
  color: #333;
}

.email-form-status {
  margin-top: 10px;
  font-size: 12px;
  color: #333;
}

.email-form-status.error {
  color: #a00;
}

.email-form-status.success {
  color: var(--color-green);
}
