/* Kojori Share Viewer - Design System */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e5e5e5;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border-color: #d1d5db;
  --accent-blue: #0066cc;
  --accent-blue-hover: #0052a3;
  --error-red: #dc3545;
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base */
html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  padding: 8px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--bg-tertiary);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 10;
  gap: 16px;
  transition: transform 0.2s ease;
}

header.hidden {
  transform: translateY(-100%);
}

.header-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.header-link:hover {
  color: var(--accent-blue);
}

.header-actions {
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text-primary);
  color: #fff;
}

.btn-primary:hover {
  background: #000;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
}

.btn-secondary.copied {
  background: var(--bg-tertiary);
}

.btn-primary svg,
.btn-secondary svg {
  flex-shrink: 0;
}

/* Main Content */
main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px;
}

.loading {
  color: var(--text-muted);
  text-align: center;
  padding: 48px;
}

/* Markdown Content Styles */
main h1, main h2, main h3, main h4, main h5, main h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

main h1:first-child,
main h2:first-child,
main h3:first-child {
  margin-top: 0;
}

main h1 { font-size: 2rem; letter-spacing: -0.02em; }
main h2 { font-size: 1.5rem; letter-spacing: -0.01em; }
main h3 { font-size: 1.25rem; }
main h4 { font-size: 1.1rem; }

main p {
  margin-bottom: 1em;
  color: var(--text-primary);
}

main a {
  color: var(--accent-blue);
  text-decoration: none;
}

main a:hover {
  text-decoration: underline;
}

main ul, main ol {
  margin-bottom: 1em;
  padding-left: 1.5em;
}

main li {
  margin-bottom: 0.25em;
}

main code {
  background: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  color: var(--text-primary);
}

main pre {
  background: var(--bg-secondary);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 1em;
  border: 1px solid var(--border-color);
}

main pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

main blockquote {
  border-left: 3px solid var(--accent-blue);
  padding-left: 16px;
  margin: 1em 0;
  color: var(--text-secondary);
}

main img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

main table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1em;
}

main th, main td {
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  text-align: left;
}

main th {
  background: var(--bg-secondary);
  font-weight: 600;
}

main tr:hover td {
  background: var(--bg-secondary);
}

main hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
}

main strong {
  font-weight: 600;
}

/* Frontmatter (YAML metadata block) */
.frontmatter {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px 16px;
  margin-bottom: 32px;
  font-size: 13px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  border-bottom: 2px solid var(--border-color);
}

.frontmatter .meta-item {
  color: var(--text-secondary);
}

.frontmatter .meta-item strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* Password Form */
#password-form {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.password-container {
  max-width: 360px;
  width: 100%;
  text-align: center;
  background: var(--bg-primary);
  padding: 40px 32px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.lock-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  color: var(--text-muted);
}

.password-container h2 {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 24px;
  color: var(--text-primary);
}

#unlock-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#password-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

#password-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.btn-unlock {
  width: 100%;
  padding: 12px;
  background: var(--text-primary);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s ease;
  font-family: inherit;
}

.btn-unlock:hover {
  background: #000;
}

.error {
  color: var(--error-red);
  font-size: 0.875rem;
  margin-top: 12px;
}

/* Footer */
footer {
  padding: 20px;
  text-align: center;
  border-top: 1px solid var(--bg-tertiary);
}

footer a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--accent-blue);
}

/* Responsive */
@media (max-width: 768px) {
  header {
    padding: 8px 12px;
  }

  .header-link {
    display: none;
  }

  .btn-secondary span {
    display: none;
  }

  .btn-secondary {
    padding: 8px 10px;
  }

  .btn-primary {
    max-width: 180px;
  }

  .btn-primary span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  main {
    padding: 32px 16px;
  }

  main h1 { font-size: 1.5rem; }
  main h2 { font-size: 1.25rem; }
  main h3 { font-size: 1.1rem; }

  .password-container {
    padding: 32px 24px;
  }

  footer {
    padding: 16px;
  }
}
