:root {
  --background: #f9fafb;
  --surface: #ffffff;
  --surface-muted: #f3f4f6;
  --text: #1f2937;
  --text-muted: #5b6472;
  --border: #e5e7eb;
  --accent: #ea580c;
  --accent-dark: #c2410c;
  --focus: #2563eb;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 18px 36px rgba(15, 23, 42, 0.14);
  --radius: 1rem;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  transform: translateY(-160%);
  border-radius: 0.5rem;
  background: var(--text);
  color: #fff;
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.container {
  width: min(100% - 2rem, 72rem);
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.header-inner {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.back-link,
.github-profile,
.refresh-button,
.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.7rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: color 200ms ease, background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease, transform 200ms ease;
}

.back-link {
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
}

.back-link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.github-profile,
.button-primary {
  padding: 0.55rem 1rem;
  background: var(--text);
  color: #fff;
}

.github-profile:hover,
.button-primary:hover {
  background: #111827;
  transform: translateY(-1px);
}

.page-main {
  flex: 1;
  padding-block: clamp(3rem, 8vw, 5.5rem);
}

.hero {
  max-width: 46rem;
  margin-bottom: 3.5rem;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.65rem;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1,
.repository-hero h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero p,
.repository-description {
  max-width: 42rem;
  margin: 1.25rem 0 0;
  color: var(--text-muted);
  font-size: clamp(1.05rem, 2vw, 1.2rem);
}

.section-heading {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.section-heading p {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
}

.refresh-button {
  flex: 0 0 auto;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.refresh-button:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.refresh-button.is-loading svg {
  animation: spin 800ms linear infinite;
}

.project-controls {
  margin: -0.25rem 0 1.25rem;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(16rem, 1.6fr) repeat(3, minmax(10rem, 1fr)) auto;
  align-items: end;
  gap: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-field label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.control-field input,
.control-field select {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.control-field input::placeholder {
  color: #9ca3af;
}

.control-field input:hover,
.control-field select:hover,
.control-field input:focus,
.control-field select:focus {
  border-color: #cbd5e1;
}

.clear-filters {
  min-height: 46px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface-muted);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease, transform 200ms ease;
}

.clear-filters:hover:not(:disabled) {
  border-color: #cbd5e1;
  background: #e5e7eb;
  transform: translateY(-1px);
}

.clear-filters:disabled {
  cursor: default;
  opacity: 0.5;
}

.notice {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid #fed7aa;
  border-radius: 0.75rem;
  background: #fff7ed;
  color: #9a3412;
}

.project-grid {
  min-height: 18rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 1.5rem;
}

.project-card {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: box-shadow 250ms ease, transform 250ms ease;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.card-cover {
  min-height: 9.5rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
}

.card-cover span {
  overflow-wrap: anywhere;
  font-size: clamp(1.55rem, 5vw, 2.25rem);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}

.language-java { background: #b45309; }
.language-javascript { background: #854d0e; }
.language-php { background: #4338ca; }
.language-html { background: #c2410c; }
.language-css { background: #1d4ed8; }
.language-python { background: #075985; }
.language-default { background: var(--accent); }

.card-body {
  flex: 1;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
}

.card-main-link {
  color: inherit;
  text-decoration: none;
}

.card-main-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.project-card {
  position: relative;
}

.card-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

.card-description {
  flex: 1;
  margin: 0.7rem 0 1.2rem;
  color: var(--text-muted);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.category-pill {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #fff7ed;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
}

.language-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: var(--accent);
}

.card-github-link {
  position: relative;
  z-index: 2;
  min-height: 44px;
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.card-github-link:hover {
  text-decoration: underline;
}

.skeleton {
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: shimmer 1.35s infinite;
}

.skeleton-cover { min-height: 9.5rem; }
.skeleton-title { width: 60%; height: 1.6rem; margin-bottom: 1rem; border-radius: 0.3rem; }
.skeleton-line { width: 100%; height: 1rem; margin-bottom: 0.65rem; border-radius: 0.3rem; }
.skeleton-line.short { width: 70%; }

.site-footer {
  padding: 2rem 0;
  color: #6b7280;
  font-size: 0.9rem;
  text-align: center;
}

.repository-hero {
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.repository-readme {
  margin-top: 1.5rem;
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.repository-preview {
  margin-top: 1.5rem;
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.repository-preview h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.preview-status,
.preview-note {
  max-width: 48rem;
  color: var(--text-muted);
}

.preview-status { margin: 1rem 0 0; }

#preview-content[hidden],
.preview-demo-link[hidden],
.preview-image-wrap[hidden] { display: none; }

.preview-facts {
  margin: 2rem 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.preview-facts div {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface-muted);
}

.preview-facts dt {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-facts dd {
  margin: 0.3rem 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.preview-note { margin: 1.25rem 0; }

.preview-demo-link { margin-bottom: 1.5rem; }

.preview-image-wrap {
  width: 100%;
  max-height: 34rem;
  margin: 1.5rem 0 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: #0f172a;
}

.preview-image-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.repository-readme[hidden] { display: none; }

.repository-readme h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.readme-content {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.readme-language {
  padding: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--surface-muted);
}

.readme-language h3 {
  margin: 0 0 0.75rem;
  color: var(--accent-dark);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.readme-language p {
  margin: 0.75rem 0 0;
  color: var(--text-muted);
}

.readme-language p:first-of-type { margin-top: 0; }

.repository-actions {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
}

.button-secondary {
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover {
  background: var(--surface-muted);
}

.repository-meta {
  margin: 2rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  list-style: none;
}

.repository-meta li {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 3rem 1.5rem;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 40rem) {
  .container { width: min(100% - 1.25rem, 72rem); }
  .github-profile { padding-inline: 0.75rem; }
  .section-heading { align-items: start; }
  .project-controls { grid-template-columns: 1fr; padding: 0.85rem; }
  .refresh-button { width: 44px; padding: 0; }
  .refresh-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .readme-content { grid-template-columns: 1fr; }
  .preview-facts { grid-template-columns: 1fr; }
}

@media (min-width: 40.01rem) and (max-width: 62rem) {
  .project-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-field-search { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .clear-filters:hover:not(:disabled) { transform: none; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
