@layer reset, base, theme, components, utilities;

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
  }
  body, h1, h2, h3, p, ul, li, figure, figcaption, blockquote, dl, dd {
    margin: 0;
    padding: 0;
  }
  ul, ol {
    list-style: none;
  }
  a {
    text-decoration: none;
    color: inherit;
  }
  img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
    height: auto;
  }
}

@layer theme {
  :root {
    --color-primary: #000000;
    --color-secondary: #00A3AF; /* Teal color from main association site */
    --color-text: #111111;
    --color-bg: #e6f6f8; /* Lighter teal/cyan base */
    --color-bubble-bg: #ffffff;
    
    --font-base: "Zen Maru Gothic", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    
    color-scheme: light;
  }
}

@layer base {
  html {
    scroll-behavior: smooth;
  }
  body {
    font-family: var(--font-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    /* Graph paper/grid pattern */
    background-image: 
      linear-gradient(rgba(0, 150, 200, 0.15) 1px, transparent 1px),
      linear-gradient(90deg, rgba(0, 150, 200, 0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    background-attachment: fixed;
    line-height: 1.6;
    text-wrap: pretty;
    font-weight: 700;
  }
  .container {
    max-width: 1000px;
    margin-inline: auto;
    padding-inline: 1rem;
  }
  h1, h2, h3 {
    text-wrap: balance;
    font-weight: 900;
  }
}

@layer components {
  .site-header {
    padding-block: 1rem;
    position: sticky;
    top: 0;
    background-color: rgba(255, 255, 255, 0.95);
    border-bottom: 4px solid var(--color-text);
    z-index: 10;
  }
  
  .header-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
  }

  .header-logos {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .main-logo-link {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--color-text);
    border-radius: 50%;
    padding: 4px;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.15);
  }


  .main-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
  }

  .branch-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border: 1px solid var(--color-text);
    border-radius: 50%;
    background: #fff;
    padding: 4px;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.15);
  }

  .site-title {
    text-align: center;
    font-size: clamp(1.1rem, 0.8rem + 1.8vw, 2rem);
    letter-spacing: 0.08em;
  }

  .x-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    background: var(--color-text);
    color: #fff;
    border: 3px solid var(--color-text);
    border-radius: 50px;
    font-weight: 900;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.15);
    transition: background-color 0.2s;
  }

  .x-link:where(:hover, :focus-visible) {
    background: var(--color-secondary);
  }

  .hero-lead {
    font-size: clamp(1.4rem, 1rem + 2vw, 2.2rem);
    font-weight: 900;
    margin-block-end: 1rem;
  }

  .news-content.news-article { text-align: left; }
  .news-article > p { margin-block-end: 1.2rem; }
  .news-article .questions {
    border-left: 5px solid var(--color-secondary);
    padding-left: 1rem;
  }
  .news-article .event-sub {
    text-align: center;
    margin-block: 2.5rem 0;
  }
  .news-article .event-title { margin-block: 0.5rem 2rem; }
  .news-article h3 {
    font-size: clamp(1.3rem, 1rem + 1.5vw, 1.8rem);
    color: var(--color-secondary);
    margin-block-end: 1rem;
  }
  .event-title {
    font-size: clamp(1.4rem, 1rem + 2vw, 2.2rem);
    font-weight: 900;
    text-align: center;
    margin-block: 2rem;
  }
  .event-info {
    display: grid;
    grid-template-columns: max-content auto;
    width: fit-content;
    margin-inline: auto;
    gap: 0.6rem 0.6rem;
    justify-items: start;
    align-items: start;
    text-align: left;
    border-top: 3px dashed var(--color-text);
    padding-top: 1.5rem;
  }
  .event-info dt {
    background: var(--color-secondary);
    color: #fff;
    padding: 0.1rem 0.8rem;
    border-radius: 20px;
    text-align: center;
  }
  .map-link {
    color: var(--color-secondary);
    border-bottom: 2px solid currentColor;
    margin-inline-start: 0.5rem;
  }
  .map-link:hover { color: #008B96; }
  .sponsor-list { display: flex; flex-wrap: wrap; }
  .sponsor-list li + li::before { content: "／"; }


  .global-nav ul {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
  }
  
  .global-nav a {
    font-weight: 900;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border: 2px solid transparent;
    border-radius: 20px;
    transition: all 0.2s ease;
  }
  
  .global-nav a:where(:hover, :focus-visible) {
    color: var(--color-secondary);
    border-color: var(--color-secondary);
    background: rgba(255, 255, 255, 0.8);
  }

  .hero {
    padding-block: 3rem 1.5rem;
    text-align: center;
  }
  
  .hero .container {
    /* Speech bubble style for hero */
    background: var(--color-bubble-bg);
    border: 5px solid var(--color-text);
    border-radius: 40px;
    padding: 3.5rem 2rem;
    position: relative;
    box-shadow: 8px 8px 0px rgba(0,0,0,0.15);
  }
  
  .hero::after {
    content: '';
    display: none; /* Can be enabled if needed */
  }
  
  .hero h2 {
    font-size: clamp(1.75rem, 1.25rem + 2.5vw, 3rem);
    margin-block-end: 1.5rem;
    color: var(--color-text);
    letter-spacing: 0.05em;
  }

  .section {
    padding-block: 1.5rem 4rem;
  }
  
  .section h2 {
    font-size: clamp(1.75rem, 1.5rem + 2vw, 2.5rem);
    text-align: center;
    margin-block-end: 2.5rem;
    color: var(--color-text);
    text-shadow: 2px 2px 0px #fff, -2px -2px 0px #fff, 2px -2px 0px #fff, -2px 2px 0px #fff;
  }
  
  .section h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 6px;
    background-color: var(--color-secondary);
    margin: 10px auto 0;
    border-radius: 3px;
  }

  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
  }

  .card, .about-content, .contact-content, .news-content {
    background: var(--color-bubble-bg);
    padding: 2.5rem;
    border-radius: 30px;
    border: 4px solid var(--color-text);
    box-shadow: 6px 6px 0px rgba(0,0,0,0.15);
    position: relative;
  }
  
  .card:where(:hover, :focus-within) {
  }
  
  .card h3 {
    margin-block-end: 1rem;
    color: var(--color-secondary);
    font-size: 1.4rem;
  }

  /* Speech bubble tails for main content blocks */
  .about-content::after, .news-content::after, .contact-content::after {
    content: '';
    position: absolute;
    bottom: -24px;
    left: 10%;
    border-width: 20px 20px 0 0;
    border-style: solid;
    border-color: var(--color-text) transparent transparent transparent;
    display: block;
    width: 0;
  }
  
  .about-content::before, .news-content::before, .contact-content::before {
    content: '';
    position: absolute;
    bottom: -15px;
    left: calc(10% + 5px);
    border-width: 15px 15px 0 0;
    border-style: solid;
    border-color: var(--color-bubble-bg) transparent transparent transparent;
    display: block;
    width: 0;
    z-index: 1;
  }

  .about-content, .contact-content, .news-content {
    max-width: 800px;
    margin-inline: auto;
    text-align: center;
  }

  .btn {
    display: inline-block;
    padding: 1rem 2.5rem;
    background-color: var(--color-secondary);
    color: #fff;
    border-radius: 50px;
    font-weight: 900;
    font-size: 1.2rem;
    text-align: center;
    border: 3px solid var(--color-text);
    box-shadow: 4px 4px 0px rgba(0,0,0,0.15);
    transition: background-color 0.2s;
  }
  
  .btn:where(:hover, :focus-visible) {
    background-color: #008B96;
    color: #fff;
  }

  .site-footer {
    padding-block: 3rem;
    text-align: center;
    background-color: var(--color-text);
    color: #fff;
    margin-top: 4rem;
    border-top: 6px solid var(--color-secondary);
  }
  /* Playwrights Section */
  .playwright-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: 2rem;
    align-items: stretch;
  }

  .playwright-card {
    background: var(--color-bubble-bg);
    border: 4px solid var(--color-text);
    border-radius: 28px;
    box-shadow: 6px 6px 0px rgba(0,0,0,0.15);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .playwright-header {
    display: flex;
    align-items: center;
    gap: 1.2rem;
  }

  .playwright-photo-wrap {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--color-text);
    box-shadow: 3px 3px 0px rgba(0,0,0,0.12);
    background: #f0f7f8;
  }

  .playwright-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .playwright-title {
    flex: 1;
    min-width: 0;
  }

  .playwright-name {
    font-size: clamp(1.3rem, 1.15rem + 0.5vw, 1.6rem);
    color: var(--color-text);
    letter-spacing: 0.05em;
    line-height: 1.3;
  }

  .playwright-name ruby {
    ruby-position: over;
  }

  .playwright-name rt {
    font-size: 0.55em;
    color: var(--color-secondary);
    font-weight: 700;
    letter-spacing: 0.02em;
  }

  .playwright-bio {
    flex-grow: 1;
    font-size: 0.95rem;
    line-height: 1.75;
    color: #222222;
  }

  .playwright-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 2px dashed rgba(0, 163, 175, 0.35);
  }

  .playwright-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text);
    background: #eaf7f9;
    border: 2px solid var(--color-text);
    border-radius: 30px;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.2;
  }

  .playwright-link-btn:where(:hover, :focus-visible) {
    background: var(--color-secondary);
    color: #ffffff;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.2);
    transform: translateY(-1px);
  }

  .playwright-link-btn svg {
    flex-shrink: 0;
  }

  @media (max-width: 640px) {
    .x-link span { display: none; }
    .x-link { padding: 0.6rem; }
    .branch-logo { width: 60px; height: 60px; }

    /* 本文の強制改行を解除し、文節単位で折り返す */
    .hero br,
    .news-article > p:not(.questions) br { display: none; }
    body { word-break: auto-phrase; }

    .hero .container { padding: 2rem 1.25rem; border-radius: 28px; }
    .news-content.news-article { padding: 1.75rem 1.25rem; border-radius: 24px; }

    /* 開催情報は項目名を上、本文を下に */
    .event-info {
      grid-template-columns: 1fr;
      width: 100%;
      gap: 0.25rem;
    }
    .event-info dt { margin-top: 0.9rem; }
    .event-info dt:first-child { margin-top: 0; }
    .event-info a { overflow-wrap: anywhere; }

    /* タイトルは1行に収める（14文字分を画面幅に合わせて縮小） */
    .news-article .event-title {
      white-space: nowrap;
      font-size: min(1.6rem, calc((100vw - 6rem) / 14));
      letter-spacing: 0;
    }

    /* 作家カード モバイル調整 */
    .playwright-grid {
      grid-template-columns: 1fr;
      gap: 1.5rem;
    }
    .playwright-card {
      padding: 1.5rem 1.25rem;
      border-radius: 24px;
    }
    .playwright-photo-wrap {
      width: 75px;
      height: 75px;
    }
  }

}

@layer utilities {
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }
}
