/* Minimal stylesheet for grit browse */

/* Vendored fonts */
@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  src: url('/browse/static/fonts/FiraSans-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 700;
  src: url('/browse/static/fonts/FiraSans-Bold.woff2') format('woff2');
}

@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 400;
  src: url('/browse/static/fonts/FiraCode-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Fira Code';
  font-style: normal;
  font-weight: 700;
  src: url('/browse/static/fonts/FiraCode-Bold.woff2') format('woff2');
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: #eee;
  background: #1a1a1a;
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #444;
  padding-bottom: 20px;
  margin-bottom: 30px;
}

header nav {
  color: #aaa;
  margin: 0;
  font-weight: normal;
}

.header-clone {
  background: #161b22;
  padding: 6px 10px;
  border-radius: 3px;
  border: 1px solid #30363d;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
  user-select: all;
  white-space: nowrap;
  margin-left: auto;
}

.header-clone:hover {
  background: #1c2128;
}

.header-clone.flash-copy {
  background: #1c2d24;
  border-color: #238636;
}

header nav strong {
  font-weight: normal;
}

nav {
  margin-top: 10px;
  color: #aaa;
}

nav a {
  color: #58a6ff;
  text-decoration: none;
}

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

main {
  min-height: 60vh;
}

h2 {
  font-size: 20px;
  margin: 20px 0 15px 0;
  font-weight: 600;
}

h3 {
  font-size: 16px;
  margin: 15px 0 10px 0;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

thead {
  background: #2d2d2d;
  border-bottom: 2px solid #444;
}

th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
}

td {
  padding: 8px 12px;
  border-bottom: 1px solid #333;
}

tbody tr:hover {
  background: #252525;
}

/* Truncate long commit messages in tables */
td:nth-child(2) {
  max-width: 500px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* File pages: remove row borders */
table.file-view td {
  border-bottom: none;
}

/* Copy hash infinity symbol */
.copy-hash {
  cursor: pointer;
  color: #768390;
  margin-left: 4px;
  margin-right: 8px;
  transition: color 0.15s ease-in-out;
  user-select: none;
}

.copy-hash:hover {
  color: #58a6ff;
}

.copy-hash.flash-copy {
  color: #238636;
}

a {
  color: #58a6ff;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* File/folder icons - prevent underline and use text emoji */
.icon {
  display: inline-block;
  text-decoration: none !important;
  font-family: 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-variation-settings: normal;
  margin-right: 4px;
  vertical-align: baseline;
}

/* Directory icons - dark grey */
.icon-dir {
  color: #666;
}

a:hover .icon {
  text-decoration: none !important;
}

code {
  font-family: 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', monospace;
  background: #0d1117;
  padding: 2px 6px;
  border-radius: 3px;
  color: #eee;
  font-size: 14px;
}

pre {
  background: #0d1117;
  padding: 16px;
  overflow-x: auto;
  border-radius: 6px;
  margin: 20px 0;
  border: 1px solid #30363d;
}

pre code {
  background: none;
  padding: 0;
}

.repo-info {
  background: #2d2d2d;
  padding: 15px;
  border-radius: 6px;
  margin: 20px 0;
}

.repo-info p {
  margin: 5px 0;
}

.repo-description {
  margin: 0 0 20px 0;
}

.clone-urls {
  margin: 20px 0;
}

.clone-command {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.clone-command code {
  flex: 1;
  background: #161b22;
  padding: 10px;
  border-radius: 3px;
  margin: 0;
  border: 1px solid #30363d;
  cursor: pointer;
  transition: background 0.15s ease-in-out;
  user-select: all;
}

.clone-command code:hover {
  background: #1c2128;
}

.clone-command code.flash-copy {
  background: #1c2d24;
  border-color: #238636;
}

.repo-meta {
  color: #aaa;
  margin: 10px 0 5px 0;
}

.repo-nav {
  margin: 20px 0;
  padding: 10px 0;
  border-bottom: 1px solid #444;
}

.repo-nav a {
  margin-right: 20px;
  padding: 5px 10px;
  display: inline-block;
}

.repo-nav a:hover {
  background: #2d2d2d;
  border-radius: 3px;
}

.commit-meta {
  color: #aaa;
  margin: 10px 0 5px 0;
}

.commit-message {
  margin: 0 0 20px 0;
}

dl {
  margin: 20px 0;
}

dt {
  font-weight: 600;
  margin-top: 10px;
}

dd {
  margin-left: 20px;
  margin-bottom: 10px;
}

footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid #444;
  color: #aaa;
  text-align: center;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #238636;
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
  font-size: 13px;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Side-by-side diff styles */
.diff-container {
  margin: 20px 0;
}

.diff-file {
  margin-bottom: 30px;
}

.diff-file h4 {
  background: #161b22;
  padding: 10px 15px;
  margin: 0;
  border: 1px solid #30363d;
  border-radius: 6px 6px 0 0;
  font-weight: 600;
  color: #eee;
}

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', monospace;
  border: 1px solid #30363d;
  border-top: none;
  margin: 0;
}

.diff-table colgroup .diff-line-num {
  width: 40px;
}

.diff-table colgroup .diff-line-old,
.diff-table colgroup .diff-line-new {
  width: 50%;
}

.diff-table thead {
  background: #161b22;
  border-bottom: 1px solid #30363d;
}

.diff-table thead th {
  padding: 5px 10px;
  font-weight: 600;
  text-align: center;
  border-right: 1px solid #30363d;
}

.diff-table thead th:last-child {
  border-right: none;
}

.diff-table tbody tr td {
  padding: 0;
  border-bottom: none;
  vertical-align: top;
}

.diff-table tbody tr:hover {
  background: none;
}

.diff-table td:nth-child(1),
.diff-table td:nth-child(3) {
  width: 40px;
  padding: 2px 8px;
  text-align: right;
  color: #768390;
  background: #0d1117;
  border-right: 1px solid #30363d;
  user-select: none;
  font-size: 14px;
}

.diff-table td:nth-child(2),
.diff-table td:nth-child(4) {
  padding: 2px 10px;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-table td:nth-child(2) {
  border-right: 1px solid #30363d;
}

.diff-table td code {
  background: none;
  padding: 0;
  white-space: pre;
}

/* Context lines */
.diff-context td:nth-child(2),
.diff-context td:nth-child(4) {
  background: #1a1a1a;
}

/* Addition lines */
.diff-add td:nth-child(4) {
  background: #1a472a;
}

.diff-add td:nth-child(3) {
  background: #1a472a;
}

/* Deletion lines */
.diff-del td:nth-child(2) {
  background: #5c1f1f;
}

.diff-del td:nth-child(1) {
  background: #5c1f1f;
}

/* Hunk headers */
.diff-hunk td {
  background: #161b22;
  padding: 5px 10px;
  color: #768390;
  font-weight: 600;
  border-top: 1px solid #30363d;
  border-bottom: 1px solid #30363d;
}

.diff-hunk code {
  color: #768390;
}

/* File view with line numbers */
.file-view {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', monospace;
  border: 1px solid #30363d;
  margin: 20px 0;
  background: #0d1117;
}

.file-view tbody tr:hover {
  background: #161b22;
}

.file-view .line-num {
  width: 50px;
  padding: 2px 10px;
  text-align: right;
  color: #768390;
  background: #0d1117;
  border-right: 1px solid #30363d;
  user-select: none;
  font-size: 14px;
  vertical-align: top;
}

.file-view .line-code {
  padding: 2px 10px;
  white-space: pre;
  background: #0d1117;
}

.file-view .line-code code {
  background: none;
  padding: 0;
  color: #eee;
}

/* Stat columns (N, +, -) - minimal width */
.stat-col {
  width: 1%;
  white-space: nowrap;
  text-align: center;
  padding: 8px 0 !important;
}

/* Log table timestamp column (desktop and all breakpoints) */
/* Log table structure: Timestamp | Commit | Message | Author | N | + | - */
.log-table td:nth-child(1),
.log-table th:nth-child(1) {
  width: 140px;
  min-width: 140px;
}

/* Log table commit column (desktop and all breakpoints) */
.log-table td:nth-child(2),
.log-table th:nth-child(2) {
  width: 120px;
  min-width: 120px;
}

/* Log table message column - truncate with ellipsis */
.log-table td:nth-child(3) {
  max-width: 500px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Log table additions column (+) - 3px padding */
.log-table td:nth-child(6) {
  padding: 8px 3px !important;
}

/* Log table deletions column (-) - 6px right padding */
.log-table td:nth-child(7) {
  padding: 8px 6px 8px 0 !important;
}

/* Syntax highlighting (highlight.js) in file view table */
/* File view table already has proper styling above, just ensure spans work */
.file-view .line-code span {
  font-family: inherit;
  white-space: pre;
}

/* Responsive design */

/* Tablet and below (< 1366px) */
/* Catches iPad Pro landscape (1366px) and standard iPad landscape (1024px) */
@media (max-width: 1366px) {
  body {
    padding: 15px;
  }

  th, td {
    padding: 6px 10px;
  }

  .repo-nav a {
    margin-right: 15px;
  }

  /* Hide size column in files table on tablet */
  /* Files table structure: Name | Last Commit | Timestamp | Size */
  /* Tablet landscape shows: Name, Last Commit, Timestamp */
  /* Tablet portrait hides Timestamp additionally (see portrait-specific rule) */
  .files-table thead th:nth-child(4),
  .files-table tbody td:nth-child(4) {
    display: none;
  }

  /* Log table on tablet landscape shows all columns */
  /* Log table structure: Timestamp | Commit | Message | Author | N | + | - */
  /* Author and diffstat columns are visible on tablet landscape, hidden on tablet portrait and mobile */

  /* Note: Timestamp and commit column widths are already set in base rules above */
  /* Log table structure: Timestamp | Commit | Message | Author | N | + | - */
  /* Note: recent-commits-table uses log-table class, so shares all log-table styles */
}

/* Tablet portrait-specific adjustments */
@media (max-width: 1366px) and (orientation: portrait) {
  /* Hide timestamp and size columns in files table on tablet portrait */
  /* Files table structure: Name | Last Commit | Timestamp | Size */
  /* Portrait shows: Name, Last Commit only */
  .files-table thead th:nth-child(3),
  .files-table thead th:nth-child(4),
  .files-table tbody td:nth-child(3),
  .files-table tbody td:nth-child(4) {
    display: none;
  }

  /* Hide author and diffstat columns in log table on tablet portrait */
  /* Log table structure: Timestamp | Commit | Message | Author | N | + | - */
  /* Portrait shows: Timestamp, Commit, Message */
  /* Note: recent-commits-table uses log-table class, so shares this behavior */
  .log-table thead th:nth-child(4),
  .log-table thead th:nth-child(5),
  .log-table thead th:nth-child(6),
  .log-table thead th:nth-child(7),
  .log-table tbody td:nth-child(4),
  .log-table tbody td:nth-child(5),
  .log-table tbody td:nth-child(6),
  .log-table tbody td:nth-child(7) {
    display: none;
  }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
  body {
    padding: 10px;
    font-size: 13px;
  }

  /* Stack header on mobile */
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
    padding-bottom: 15px;
    margin-bottom: 20px;
  }

  header nav {
    word-break: break-word;
  }

  .header-clone {
    margin-left: 0;
    width: 100%;
    text-align: center;
    font-size: 12px;
  }

  /* Reduce heading sizes */
  h2 {
    font-size: 18px;
    margin: 15px 0 10px 0;
  }

  h3 {
    font-size: 15px;
  }

  /* Make tables horizontally scrollable */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 15px 0;
  }

  thead, tbody, tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  th, td {
    padding: 6px 8px;
    font-size: 13px;
  }

  /* Optimize first column width on mobile */
  /* Files: filename, Logs: commit hash, Refs: branch/tag name */
  table td:first-child,
  table th:first-child {
    width: 35%;
    min-width: 80px;
  }

  /* Second column gets remaining space */
  table td:nth-child(2),
  table th:nth-child(2) {
    width: 65%;
  }

  /* Adjust commit message truncation for mobile */
  td:nth-child(2) {
    max-width: 200px;
  }

  /* Hide timestamp column on mobile for files table */
  /* Files table structure: Name | Last Commit | Author | Timestamp | Size */
  /* Tablet landscape shows Timestamp, tablet portrait and mobile hide it */
  .files-table thead th:nth-child(4),
  .files-table tbody td:nth-child(4) {
    display: none;
  }

  /* Hide author and diffstat columns on mobile for log table */
  /* Log table structure: Timestamp | Commit | Message | Author | N | + | - */
  /* Mobile shows: Timestamp, Commit, Message */
  .log-table thead th:nth-child(4),
  .log-table thead th:nth-child(5),
  .log-table thead th:nth-child(6),
  .log-table thead th:nth-child(7),
  .log-table tbody td:nth-child(4),
  .log-table tbody td:nth-child(5),
  .log-table tbody td:nth-child(6),
  .log-table tbody td:nth-child(7) {
    display: none;
  }

  /* Minimize timestamp column width in log table on mobile */
  .log-table td:first-child,
  .log-table th:first-child {
    width: 120px;
    min-width: 120px;
  }

  /* Minimize commit hash column width in log table on mobile */
  .log-table td:nth-child(2),
  .log-table th:nth-child(2) {
    width: 90px;
    min-width: 90px;
  }

  /* Give message column remaining space in log table */
  .log-table td:nth-child(3),
  .log-table th:nth-child(3) {
    width: auto;
  }

  /* Hide author and timestamp columns on mobile for refs table */
  /* Refs table structure: Branch/Tag | Last Commit | Author | Timestamp */
  /* Mobile shows only Branch/Tag and Last Commit */
  .refs-table thead th:nth-child(3),
  .refs-table thead th:nth-child(4),
  .refs-table tbody td:nth-child(3),
  .refs-table tbody td:nth-child(4) {
    display: none;
  }

  /* Branch/tag name column width in refs table on mobile */
  /* Using percentage because ref names can be long (unlike fixed-length hashes) */
  .refs-table td:first-child,
  .refs-table th:first-child {
    width: 25%;
    min-width: 80px;
  }

  /* Give last commit column remaining space in refs table */
  .refs-table td:nth-child(2),
  .refs-table th:nth-child(2) {
    width: 75%;
  }

  /* Break long filenames on mobile */
  /* Files table: prevent long filenames from breaking layout */
  .files-table td:first-child {
    max-width: 35%;
    word-break: break-all;
  }


  /* Hide Last Updated column in repository index tables on mobile */
  /* Repo index table structure: Repository | Description | Last Updated */
  /* Mobile shows only Repository and Description */
  .repo-index-table thead th:nth-child(3),
  .repo-index-table tbody td:nth-child(3) {
    display: none;
  }

  /* Tighter spacing for repo nav */
  .repo-nav {
    margin: 15px 0;
    padding: 8px 0;
  }

  .repo-nav a {
    margin-right: 10px;
    padding: 4px 8px;
    font-size: 13px;
  }

  /* Compact repo info */
  .repo-info {
    padding: 12px;
    margin: 15px 0;
  }

  .repo-meta, .commit-meta {
    font-size: 12px;
  }

  /* Code blocks */
  code {
    font-size: 12px;
    padding: 2px 4px;
  }

  pre {
    padding: 12px;
    font-size: 12px;
    margin: 15px 0;
  }

  /* Clone command blocks */
  .clone-command {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .clone-command code {
    padding: 8px;
    font-size: 12px;
  }

  /* Diff tables on mobile - switch to unified view */
  .diff-table {
    font-size: 12px;
  }

  .diff-table td:nth-child(1),
  .diff-table td:nth-child(3) {
    padding: 2px 4px;
    font-size: 11px;
  }

  .diff-table td:nth-child(2),
  .diff-table td:nth-child(4) {
    padding: 2px 6px;
    font-size: 12px;
  }

  /* File view */
  .file-view {
    font-size: 12px;
  }

  .file-view .line-num {
    width: 40px;
    padding: 2px 6px;
    font-size: 11px;
  }

  .file-view .line-code {
    padding: 2px 6px;
    font-size: 12px;
  }

  /* Toast already optimized globally */

  /* Footer */
  footer {
    margin-top: 40px;
    padding-top: 15px;
    font-size: 12px;
  }

  /* Definition lists */
  dd {
    margin-left: 15px;
    font-size: 13px;
  }
}

/* Very small mobile (< 480px) */
@media (max-width: 480px) {
  body {
    padding: 8px;
    font-size: 12px;
  }

  header {
    gap: 12px;
  }

  .header-clone {
    font-size: 11px;
    padding: 5px 8px;
  }

  h2 {
    font-size: 16px;
  }

  th, td {
    padding: 5px 6px;
    font-size: 12px;
  }

  /* Very compact nav */
  .repo-nav a {
    margin-right: 8px;
    padding: 3px 6px;
    font-size: 12px;
  }

  code {
    font-size: 11px;
  }

  pre {
    font-size: 11px;
    padding: 10px;
  }

  /* Toast already optimized globally */
}
