/* Custom overrides for navbar dropdown behavior */

/* Let expanded submenu match actual content height instead of fixed 250px */
.navbar .dropdown.nav-item .dropdown-menu-animation.show {
  height: auto !important;
}

/* Disable forced scroll behavior for nav-item dropdowns */
.navbar-toggler + .navbar-collapse .dropdown.nav-item .dropdown-menu {
  overflow: visible !important;
}

/* Align text start positions by giving navbar icons a fixed slot width */
.navbar .navbar-collapse .navbar-nav .nav-link .material-symbols-outlined {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  min-width: 1.5rem;
  flex: 0 0 1.5rem;
  font-weight: 600;
  opacity: 0.9 !important;
}

/* Make navbar font bold */
.navbar .navbar-collapse .navbar-nav .nav-link {
  font-weight: 600;
  opacity: 0.9;
}

/* Header banner height tuning: compact on phones, taller on desktop */
.top-banner {
  aspect-ratio: 5 / 1;
  position: relative;
  overflow: hidden;
  --top-banner-container-max: 100vw;
  --top-banner-container-pad: 0.75rem;
  --top-banner-card-margin: 1rem;
  --top-banner-overlay-height: 20%;
  --top-banner-overlay-y: 60%;
  --top-banner-overlay-right: calc((100vw - min(100vw, var(--top-banner-container-max))) / 2 + var(--top-banner-container-pad) + var(--top-banner-card-margin));
}

.top-banner-title {
  position: absolute;
  left: calc((100vw - min(100vw, var(--top-banner-container-max))) / 2 + var(--top-banner-container-pad) + var(--top-banner-card-margin));
  bottom: calc(100% - (var(--top-banner-overlay-y) + (var(--top-banner-overlay-height) / 2)));
  max-width: calc(100% - 1rem);
  z-index: 2;
  color: #fff;
  opacity: 0.8;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  line-height: 1.15;
  pointer-events: none;
}

.top-banner-title-sub {
  font-size: clamp(0.74rem, 1.4vw, 1.05rem);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.top-banner-title-main {
  margin-top: 0.12em;
  font-size: clamp(1.24rem, 2.65vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.title-full {
  display: block;
}

.title-short {
  display: none;
}

.top-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('../img/ut_icrr.svg');
  background-repeat: no-repeat;
  background-position: calc(100% - var(--top-banner-overlay-right)) var(--top-banner-overlay-y);
  background-size: auto var(--top-banner-overlay-height);
  z-index: 1;
  opacity: 0.8;
  pointer-events: none;
}

@media (max-width: 991.98px) {
  .top-banner {
    --top-banner-overlay-y: 12%;
  }
}

@media (max-width: 767.98px) {
  .top-banner {
    --top-banner-overlay-height: 20%;
    --top-banner-overlay-y: 12%;
  }
}

@media (max-width: 575.98px) {
  .top-banner {
    aspect-ratio: 3 / 1;
    --top-banner-overlay-height: 18%;
    --top-banner-overlay-y: 8%;
  }

  .top-banner-title {
    top: 7.4%;
  }

  .title-full {
    display: none;
  }

  .title-short {
    display: block;
  }
}

@media (max-width: 991.98px) {
  .top-banner-title {
    top: 9.6%;
    bottom: auto;
    left: calc((100vw - min(100vw, var(--top-banner-container-max))) / 2 + var(--top-banner-container-pad) + var(--top-banner-card-margin) + 3.8rem);
    max-width: calc(100% - 1.5rem);
  }

  .top-banner-title-sub {
    font-size: 0.62rem;
  }

  .top-banner-title-main {
    font-size: 1.08rem;
  }

}

@media (min-width: 576px) {
  .top-banner {
    --top-banner-overlay-height: 25%;
    --top-banner-container-max: 540px;
  }
}

@media (min-width: 768px) {
  .top-banner {
    --top-banner-container-max: 720px;
    --top-banner-card-margin: 1.5rem;
  }
}

@media (min-width: 992px) {
  .top-banner {
    --top-banner-container-max: 960px;
  }
}

@media (min-width: 1200px) {
  .top-banner {
    --top-banner-container-max: 1140px;
  }
}

@media (min-width: 1400px) {
  .top-banner {
    --top-banner-container-max: 1320px;
  }
}

/* Swap desktop dropdown arrow color after navbar scroll state changes */
.navbar.navbar-transparent .navbar-nav .nav-link .arrow-dark {
  display: none !important;
}

.navbar:not(.navbar-transparent) .navbar-nav .nav-link .arrow-white {
  display: none !important;
}

@media (min-width: 992px) {
  .navbar:not(.navbar-transparent) .navbar-nav .nav-link .arrow-dark {
    display: inline-block !important;
  }
}

/* Make all dropdown dividers visible */
.navbar .dropdown-menu .dropdown-divider {
  border-top: 1px solid rgba(38, 38, 38, 0.25);
  margin: 0.5rem 0;
  opacity: 1;
}

/* Keep hovered desktop submenus inside the viewport */
@media (min-width: 992px) {
  .navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu {
    left: 0;
    right: auto;
    min-width: 22.5rem;
    margin-left: 0 !important;
    max-width: min(90vw, 30rem);
  }

  .navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu:before {
    left: 28px !important;
    right: auto !important;
  }

  /* Keep right-edge dropdowns inside viewport */
  .navbar .navbar-collapse .navbar-nav > .nav-item.dropdown:nth-last-child(-n+3) .dropdown-menu {
    left: auto;
    right: 0;
  }

  .navbar .navbar-collapse .navbar-nav > .nav-item.dropdown:nth-last-child(-n+3) .dropdown-menu:before {
    left: auto !important;
    right: 28px !important;
  }

  .navbar .navbar-collapse .navbar-nav .nav-item.dropdown .dropdown-menu .dropdown-item {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* Offset anchor jump targets so they are not hidden behind the fixed navbar */
h1, h2, h3, h4, h5, h6 {
  scroll-margin-top: 70px;
}

/* Reduce heading scale: h1->h3, h2->h4, h3->h5 */
h1 {
  font-size: calc(1.3125rem + 0.75vw);
}

h2 {
  font-size: calc(1.275rem + 0.3vw);
}

h3 {
  font-size: 1.25rem;
}

@media (min-width: 1200px) {
  h1 {
    font-size: 1.875rem;
  }

  h2 {
    font-size: 1.5rem;
  }
}

/* Indent first line of body paragraphs on Japanese pages */
html[lang="ja"] .card-body p:not(.post-meta):not(.no-indent):not(.card-text) {
  text-indent: 1em;
}

/* Restore default browser link styles in post body text */
.post .post-content a:any-link {
  color: revert !important;
  text-decoration: revert;
}

.post .post-content a:visited {
  color: revert !important;
}

/* Style markdown tables with alternating row colors inside page content */
.card-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  table-layout: fixed;
}

/* Allow text wrapping in the project name column */
.table-project-col {
  white-space: normal !important;
  width: 36%;
}

.card-body table th:first-child,
.card-body table td:first-child {
  width: 36%;
}

.card-body table th:not(:first-child),
.card-body table td:not(:first-child) {
  width: 8%;
}

.card-body table th,
.card-body table td {
  padding: 0.5rem 0.75rem;
  border-left: none;
  border-right: none;
}

/* Keep caption text aligned with table cell content on all content tables */
.card-body table > caption {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  text-align: left;
  font-size: 0.875rem;
}

/* Remove Bootstrap top border that appears between caption and header */
.card-body .table > caption + thead,
.card-body .table > caption + tbody {
  border-top-width: 0 !important;
}

/* Allow horizontal scrolling for tables inside .table-responsive */
.table-responsive table {
  table-layout: auto;
  width: auto;
  min-width: 100%;
}

.table-responsive table th,
.table-responsive table td {
  white-space: nowrap;
}

.table-responsive .table-project-col {
  white-space: normal;
  min-width: 10rem;
}

/* Reduce table text size on narrow screens to mitigate overflow */
@media (max-width: 576px) {
  .table-responsive table {
    font-size: clamp(0.72rem, 2.7vw, 0.9rem);
  }

  .table-responsive table th,
  .table-responsive table td {
    padding: 0.4rem 0.5rem;
  }
}

/* Ensure text-dark tables stay dark even with Material Kit defaults */
.card-body table.text-dark th,
.card-body table.text-dark td,
.card-body table.text-dark small {
  color: var(--bs-dark) !important;
}

/* Use browser-default link colors in page content */
.page .card-body a,
.page .card-body a:visited,
.page .card-body a:hover,
.page .card-body a:active {
  color: revert;
}

.card-body a.external-link::after {
  content: "\f08e";
  font-family: "Font Awesome 6 Free", "Font Awesome 5 Free";
  font-weight: 900;
  display: inline-block;
  margin-left: 0.2em;
  margin-right: 0.4em;
  font-size: 0.75em;
  line-height: 1;
  vertical-align: text-top;
  opacity: 0.75;
}

/* Make only social cards use dark text; do not affect alerts */
.page .social-card p,
.page .social-card small {
  color: #262626 !important;
  opacity: 1;
}

/* Preserve image aspect ratio */
.card-img-top {
  height: auto;
}

/* Partial-collapse toggle trigger */
a[data-collapse-partial] {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
}

a[data-collapse-partial]::after {
  content: '\25BC'; /* ▼ */
  font-size: 0.65em;
  opacity: 0.5;
  transition: transform 0.3s ease, opacity 0.2s;
  display: inline-block;
}

a[data-collapse-partial][aria-expanded="true"]::after {
  transform: rotate(-180deg);
  opacity: 0.8;
}

a[data-collapse-partial]:hover::after,
a[data-collapse-partial]:focus::after {
  opacity: 1;
}

a[data-collapse-partial]:focus {
  outline: none;
}

/* Partial-collapse: show a preview with a gradient fade at the bottom */
.collapse-partial {
  max-height: 8em;
  overflow: hidden;
  position: relative;
  transition: max-height 0.4s ease;
}

.collapse-partial::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3em;
  background: linear-gradient(to bottom, transparent, var(--bs-card-bg, #fff));
  pointer-events: none;
}

.collapse-partial.is-expanded {
  max-height: 60em;
}

.collapse-partial.is-expanded::after {
  display: none;
}

/* Graphical transit route steps */
.route-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 5px;
  margin: 0.35rem 0;
  font-size: 0.88em;
}

.route-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px 2px 5px;
  border-radius: 4px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  line-height: 1.6;
}

.route-label .material-symbols-outlined {
  font-size: 1.3em;
  opacity: 1 !important;
  width: auto;
  min-width: auto;
  flex: none;
  font-weight: 400;
}

.route-steps-arrow {
  color: #aaa;
  font-size: 0.85em;
  padding: 0 1px;
}

/* JR East 路線記号 – 角丸正方形バッジ（SVG公式デザイン準拠） */
/* JY: 山手線 #B1CB39 / JK: 京浜東北線 #1DAED1 （出典: JR東日本） */
.route-badge-jr {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  height: 1.7em;
  flex-shrink: 0;
  border-radius: 0.22em;      /* 19.75 / 170 ≈ 11.6% */
  background: #fff;
  border: 0.21em solid;       /* 18.6 / 170 ≈ 10.9% */
  box-sizing: border-box;
  color: #222;
  line-height: 1;
  vertical-align: middle;
  gap: 0;
  padding: 0;
}
.badge-line {
  font-size: 0.52em;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  top: 0.1em;
}
.badge-num {
  font-size: 0.9em;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  vertical-align: middle;
}
.route-badge-jy { border-color: #B1CB39; } /* 山手線 */
.route-label-jy { background-color: #B1CB39; } /* 山手線 */
.route-badge-jk { border-color: #1DAED1; } /* 京浜東北線 */
.route-label-jk { background-color: #1DAED1; } /* 京浜東北線 */
.route-badge-jb { border-color: #EDC81B; } /* 総武線 */
.route-label-jb { background-color: #EDC81B; } /* 総武線 */
.route-badge-jj { border-color: #20A26A; } /* 常磐線 */
.route-label-jj { background-color: #20A26A; } /* 常磐線 */
.route-badge-jc { border-color: #D25428; } /* 中央線 */
.route-label-jc { background-color: #D25428; } /* 中央線 */
.route-badge-tx { border-color: #C40011; } /* つくばエクスプレス */
.route-label-tx { background-color: #C40011; } /* つくばエクスプレス */
.route-badge-ta { border-color: #0072bc; } /* 名鉄空港線 */
.route-label-ta { background-color: #0072bc; } /* 名鉄空港線 */

/* Nagoya Municipal Subway station symbol style (circle) */
.route-badge-nagoya {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  height: 1.7em;
  flex-shrink: 0;
  border-radius: 50%;
  box-sizing: border-box;
  color: #222;
  background: #fff;
  line-height: 1;
  vertical-align: middle;
  gap: 0;
  padding: 0;
  border: 0.21em solid;
}

.route-badge-nagoya .badge-line {
  font-size: 0.52em;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  top: 0.1em;
}

.route-badge-nagoya .badge-num {
  font-size: 0.9em;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  vertical-align: middle;
}

/* Nagoya Subway lines */
.route-badge-h { border-color: #FAB123;} /* 東山線 H */
.route-label-h { background-color: #FAB123;} /* 東山線 H */
.route-badge-m { border-color: #B074D6;} /* 名城線 M */
.route-label-m { background-color: #B074D6;} /* 名城線 M */
.route-badge-s { border-color: #C92F44;} /* 桜通線 S */
.route-label-s { background-color: #C92F44;} /* 桜通線 S */
.route-badge-t { border-color: #009bbf;} /* 鶴舞線 T */
.route-label-t { background-color: #009bbf;} /* 鶴舞線 T */
.route-badge-k { border-color: #EC78B4;} /* 上飯田線 K */
.route-label-k { background-color: #EC78B4;} /* 上飯田線 K */

.route-label-tobu      { background-color: #E97224; } /* バス */
.route-label-todai     { background: linear-gradient(135deg, #F8B009 0%, #F8B009 50%, #1767B4 50%, #1767B4 100%); } /* 東大 */
.route-label-walk     { background-color: #6c757d; } /* 徒歩 */

/* Table of Contents styling */
#markdown-toc {
  background-color: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 0.75rem 1rem 0.75rem 2rem;
  margin: 1rem 0;
  width: fit-content;
  max-width: 100%;
  line-height: 1.4;
}

#markdown-toc ul {
  list-style-type: none;
  padding-left: 0;
  margin: 0;
}

#markdown-toc li {
  margin-bottom: 0.4rem;
  white-space: nowrap;
}

#markdown-toc li ul {
  padding-left: 1.5rem;
  margin-top: 0.4rem;
}

#markdown-toc a {
  text-decoration: none;
  color: #0066cc;
  transition: color 0.2s ease;
}

#markdown-toc a:hover {
  color: #0052a3;
  text-decoration: underline;
}
