/* ============================================
   Y's Talk Archive — Modern CSS
   Responsive, UTF-8, archive-friendly
   ============================================ */

:root {
  --coral:    #cc4444;
  --coral-lt: #ff8080;
  --coral-bg: #fff5f5;
  --teal:     #007a7a;
  --text:     #333333;
  --muted:    #666666;
  --border:   #e0d0d0;
  --bg:       #fffdf9;
  --nav-bg:   #2a2a2a;
  --nav-text: #f0f0f0;
  --card-bg:  #ffffff;
  --max-w:    860px;
  --radius:   6px;
  --shadow:   0 2px 8px rgba(0,0,0,.08);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic",
               "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Header / Navigation ---- */
.site-header {
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.site-header .inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: .7rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--coral-lt);
  text-decoration: none;
  letter-spacing: .05em;
  white-space: nowrap;
}
.site-logo:hover { color: #ffffff; }

.main-nav {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
}
.main-nav a {
  color: var(--nav-text);
  text-decoration: none;
  font-size: .85rem;
  padding: .3rem .75rem;
  border-radius: 3px;
  border: 1px solid #555;
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.main-nav a:hover {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
}

/* ---- Main content ---- */
main {
  flex: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
  padding: 2rem 1.2rem 3rem;
}

/* ---- Footer ---- */
.site-footer {
  background: #222;
  color: #aaa;
  text-align: center;
  font-size: .8rem;
  padding: 1.2rem;
  margin-top: auto;
}
.site-footer a { color: var(--coral-lt); text-decoration: none; }

/* ---- Archive notice banner ---- */
.archive-notice {
  background: #fffbe6;
  border-left: 4px solid #e6c200;
  padding: .6rem 1rem;
  font-size: .82rem;
  color: #665500;
  margin-bottom: 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.4;
  margin-top: 1.4em;
  margin-bottom: .5em;
  color: var(--coral);
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; border-bottom: 2px solid var(--border); padding-bottom: .3rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p  { margin-bottom: .9em; }
a  { color: var(--coral); }
a:hover { color: var(--teal); }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

blockquote {
  border-left: 3px solid var(--coral-lt);
  padding: .5rem 1rem;
  margin: 1rem 0 1rem 1rem;
  color: var(--muted);
}

ul, ol {
  padding-left: 1.5em;
  margin-bottom: .9em;
}
li { margin-bottom: .3em; }

/* ---- Images ---- */
img {
  max-width: 100% !important;  /* override inline width */
  height: auto !important;     /* override inline height — prevent squish */
  display: block;
  border-radius: var(--radius);
}
/* small thumbnails inline */
p img, td img, li img {
  display: inline;
  border-radius: 3px;
  vertical-align: middle;
}

/* ---- Tables ---- */
/* Prevent any table from breaking out of viewport */
table {
  border-collapse: collapse;
  max-width: 100%;
  width: 100%;
  table-layout: auto;
}
td, th {
  max-width: 100%;
  word-break: break-word;
}

/* scrollable wrapper for wide tables */
.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

/* Prevent the page itself from overflowing horizontally */
main {
  overflow-x: hidden;
}

/* data-like tables */
table[border="1"], table.data-table {
  width: 100%;
  border: 1px solid var(--border);
  font-size: .9rem;
}
table[border="1"] th,
table[border="1"] td,
table.data-table th,
table.data-table td {
  border: 1px solid var(--border);
  padding: .4rem .6rem;
  vertical-align: top;
}
table[border="1"] tr:nth-child(even),
table.data-table tr:nth-child(even) {
  background: var(--coral-bg);
}

/* legacy layout tables — keep them usable */
table[width="100%"] { width: 100% !important; }
td, th { vertical-align: top; }

/* ---- Preformatted / code ---- */
pre, code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: .88em;
  background: #f4f4f4;
  border-radius: 3px;
}
pre { padding: 1rem; overflow-x: auto; }
code { padding: .1em .3em; }

/* ---- Page-level cards ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

/* ---- Talk list (for talkative/index) ---- */
.talk-list { list-style: none; padding: 0; }
.talk-list li {
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: .6rem;
}
.talk-list li:last-child { border-bottom: none; }
.talk-num {
  font-size: .75rem;
  background: var(--coral);
  color: #fff;
  padding: .1rem .45rem;
  border-radius: 3px;
  white-space: nowrap;
}
.talk-date { font-size: .78rem; color: var(--muted); white-space: nowrap; }

/* ---- Photo grid ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .8rem;
  margin: 1rem 0;
}
.photo-grid img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .2s;
}
.photo-grid img:hover { transform: scale(1.03); }

/* ---- Section heading bar (like original bgcolor="#009999") ---- */
.section-bar {
  background: var(--coral-bg);
  border-left: 4px solid var(--coral);
  padding: .4rem .8rem;
  font-weight: 700;
  margin: 1.2rem 0 .6rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .site-header .inner { gap: .8rem; }
  .site-logo { font-size: 1.1rem; }
  .main-nav a { font-size: .78rem; padding: .25rem .55rem; }
  main { padding: 1.2rem .9rem 2rem; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  blockquote { margin-left: 0; }

  /* Stack layout-table columns vertically on mobile */
  /* Only applies when table has no border (= layout table, not data table) */
  table[border="0"] td,
  table[border="0"] th,
  table:not([border]) td,
  table:not([border]) th {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  /* But keep data tables (border="1") horizontal with scroll */
  table[border="1"] {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table[border="1"] td,
  table[border="1"] th {
    display: table-cell !important;
    width: auto !important;
  }
}

/* ---- Legacy element compatibility ---- */
/* <center> still works but add fallback */
center { text-align: center; }
/* <font> tags are inherited—allow coloring via CSS var where possible */
font[color="#ff6666"] { color: var(--coral); }
font[color="#009999"], font[color="#0099cc"] { color: var(--teal); }
